#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int atoi(char const *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int);
char *regla2(const char *year, const char *month, const char *day,
             char *result) {
  int ano = 0;
  int mes = 0;
  int dia = 0;
  ano = atoi(year) % 100;
  mes = atoi(month);
  dia = atoi(day);
  snprintf(result, 7, "%02d%02d%02d", ano, mes, dia);
  return result;
}


x86 assembly (clang, -O0):
<regla2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <atoi@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    $0x7,%esi
lea    0xe6c(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<regla2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
call   1040 <atoi@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
mov    %r15,%rdi
call   1040 <atoi@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <atoi@plt>
lea    0xe95(%rip),%rdx
mov    %r12,%rdi
mov    $0x7,%esi
mov    %ebx,%ecx
mov    %ebp,%r8d
mov    %eax,%r9d
call   1030 <snprintf@plt>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%02d%02d%02d\00"
define i8* @regla2(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
%12 = load i8*, i8** %5
%13 = call i32 @atoi(i8* %12)
%14 = srem i32 %13, 100
store i32 %14, i32* %9
%15 = load i8*, i8** %6
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %10
%17 = load i8*, i8** %7
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %11
%19 = load i8*, i8** %8
%20 = load i32, i32* %9
%21 = load i32, i32* %10
%22 = load i32, i32* %11
%23 = call i32 @snprintf(i8* %19, i32 7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21, i32 %22)
%24 = load i8*, i8** %8
ret i8* %24
}

LLVM IR (-O2):
@.str = [13 x i8] c"%02d%02d%02d\00"
define i8* @regla2(i8* nocapture %0, i8* nocapture %1, i8* nocapture %2, i8* returned %3) {
%5 = tail call i32 @atoi(i8* %0)
%6 = srem i32 %5, 100
%7 = tail call i32 @atoi(i8* %1)
%8 = tail call i32 @atoi(i8* %2)
%9 = tail call i32 @snprintf(i8* %3, i32 7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7, i32 %8)
ret i8* %3
}