#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 /*<<< orphan*/ print(char *);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ scanf(char *, int *);
void ex3() {
  print("\n------------------------------\n");
  int ano, leap;
  print("Informe um ano: ");
  scanf("%d", &ano);
  if (!(ano % 4 == 0)) {
    leap = 0;
  } else if (!(ano % 100 == 0)) {
    leap = 1;
  } else if (!(ano % 400 == 0)) {
    leap = 0;
  } else {
    leap = 1;
  }
  printf("O ano %04d %se bissexto.\n", ano, leap == 1 ? "" : "nao ");
  print("\n------------------------------\n");
}


x86 assembly (clang, -O0):
<ex3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1040 <print@plt>
lea    0xed6(%rip),%rdi
call   1040 <print@plt>
lea    0xedb(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1180 <ex3+0x50>
movl   $0x0,-0x8(%rbp)
jmp    11d1 <ex3+0xa1>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11a0 <ex3+0x70>
movl   $0x1,-0x8(%rbp)
jmp    11cc <ex3+0x9c>
mov    -0x4(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11c0 <ex3+0x90>
movl   $0x0,-0x8(%rbp)
jmp    11c7 <ex3+0x97>
movl   $0x1,-0x8(%rbp)
jmp    11cc <ex3+0x9c>
jmp    11d1 <ex3+0xa1>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%ecx
lea    0xe71(%rip),%rdx
lea    0xe3b(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdx
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
lea    0xe01(%rip),%rdi
call   1040 <print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex3>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <print@plt>
lea    0xedd(%rip),%rdi
call   1040 <print@plt>
lea    0xee2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   $0x3,%sil
je     116d <ex3+0x3d>
lea    0xee4(%rip),%rdx
jmp    11a8 <ex3+0x78>
imul   $0xc28f5c29,%esi,%eax
add    $0x51eb850,%eax
mov    %eax,%ecx
ror    $0x2,%ecx
cmp    $0x28f5c28,%ecx
jbe    118e <ex3+0x5e>
lea    0xe94(%rip),%rdx
jmp    11a8 <ex3+0x78>
ror    $0x4,%eax
cmp    $0xa3d70b,%eax
lea    0xe83(%rip),%rax
lea    0xeab(%rip),%rdx
cmovb  %rax,%rdx
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
lea    0xe45(%rip),%rdi
call   1040 <print@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0A------------------------------\0A\00"
@.str.1 = [17 x i8] c"Informe um ano: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [26 x i8] c"O ano %04d %se bissexto.\0A\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [5 x i8] c"nao \00"
define void @ex3() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @print(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = srem i32 %6, 4
%8 = icmp eq i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %0
store i32 0, i32* %2
br label %23
10: ; preds = %0
%11 = load i32, i32* %1
%12 = srem i32 %11, 100
%13 = icmp eq i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %10
store i32 1, i32* %2
br label %22
15: ; preds = %10
%16 = load i32, i32* %1
%17 = srem i32 %16, 400
%18 = icmp eq i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %15
store i32 0, i32* %2
br label %21
20: ; preds = %15
store i32 1, i32* %2
br label %21
21: ; preds = %20, %19
br label %22
22: ; preds = %21, %14
br label %23
23: ; preds = %22, %9
%24 = load i32, i32* %1
%25 = load i32, i32* %2
%26 = icmp eq i32 %25, 1
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0)
%29 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %24, i8* %28)
%30 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"\0A------------------------------\0A\00"
@.str.1 = [17 x i8] c"Informe um ano: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [26 x i8] c"O ano %04d %se bissexto.\0A\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [5 x i8] c"nao \00"
define void @ex3() {
%1 = alloca i32
%2 = tail call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @print(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = and i32 %6, 3
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %0
%10 = srem i32 %6, 100
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = srem i32 %6, 400
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0)
br label %16
16: ; preds = %12, %9, %0
%17 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %0 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), %9 ], [ %15, %12 ]
%18 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %6, i8* %17)
%19 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret void
}