#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 *);
int timesteps(int yy, int mt) {
  int val;
  char *regular[] = {"31", "28", "31", "30", "31", "30",
                     "31", "31", "30", "31", "30", "31"};
  char *leap[] = {"31", "29", "31", "30", "31", "30",
                  "31", "31", "30", "31", "30", "31"};
  if (yy % 4 != 0)
    val = atoi(regular[mt % 12]);
  if (yy % 4 == 0)
    val = atoi(leap[mt % 12]);
  return val;
}


x86 assembly (clang, -O0):
<timesteps>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
lea    0x2c24(%rip),%rsi
mov    $0x60,%edx
call   1030 <memcpy@plt>
lea    -0xd0(%rbp),%rdi
lea    0x2c6c(%rip),%rsi
mov    $0x60,%edx
call   1030 <memcpy@plt>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     118d <timesteps+0x6d>
mov    -0x8(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x70(%rbp,%rax,8),%rdi
call   1040 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11bf <timesteps+0x9f>
mov    -0x8(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0xd0(%rbp,%rax,8),%rdi
ff
call   1040 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timesteps>:
movslq %esi,%rax
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
test   $0x3,%dil
cltq
lea    0x2c84(%rip),%rcx
lea    0x2c1d(%rip),%rdx
cmove  %rcx,%rdx
mov    (%rdx,%rax,8),%rdi
jmp    1030 <atoi@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"31\00"
@.str.1 = [3 x i8] c"28\00"
@.str.2 = [3 x i8] c"30\00"
@__const.timesteps.regular = [12 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0)]
@.str.3 = [3 x i8] c"29\00"
@__const.timesteps.leap = [12 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0)]
define i32 @timesteps(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [12 x i8*]
%7 = alloca [12 x i8*]
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = bitcast [12 x i8*]* %6 to i8*
%9 = bitcast [12 x i8*]* %7 to i8*
%10 = load i32, i32* %3
%11 = srem i32 %10, 4
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* %4
%15 = srem i32 %14, 12
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [12 x i8*], [12 x i8*]* %6, i64 0, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %5
br label %20
20: ; preds = %13, %2
%21 = load i32, i32* %3
%22 = srem i32 %21, 4
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load i32, i32* %4
%26 = srem i32 %25, 12
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [12 x i8*], [12 x i8*]* %7, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %5
br label %31
31: ; preds = %24, %20
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
@.str = [3 x i8] c"31\00"
@.str.1 = [3 x i8] c"28\00"
@.str.2 = [3 x i8] c"30\00"
@__const.timesteps.regular = [12 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0)]
@.str.3 = [3 x i8] c"29\00"
@__const.timesteps.leap = [12 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0)]
define i32 @timesteps(i32 %0, i32 %1) {
%3 = and i32 %0, 3
%4 = icmp eq i32 %3, 0
%5 = srem i32 %1, 12
%6 = sext i32 %5 to i64
%7 = select i1 %4, [12 x i8*]* @__const.timesteps.leap, [12 x i8*]* @__const.timesteps.regular
%8 = getelementptr inbounds [12 x i8*], [12 x i8*]* %7, i64 0, i64 %6
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
ret i32 %10
}