#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 f_calculate(int);
int /*<<< orphan*/ printf(char *);
int main() {
  int i = 0;
  printf("------------------------------------------------------|\n");
  printf("|Integer -> Binary Converting Program                 |\n");
  printf("|                                                     |\n");
  printf("|Use:                                                 |\n");
  printf("|Input a positive integer.                            |\n");
  printf("|The result is the numbers binary array               |\n");
  printf("|in reverse order.                                    |\n");
  printf("|                                                     |\n");
  printf("|-----------------------------------------------------|\n");
  printf("\n");
  while (i == 0) {
    int ret;
    ret = f_calculate(i);
    i = ret;
  }
  printf("Thanks for using this program\n");
  printf("EAP / exercise 1 / theme 3\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
call   1030 <printf@plt>
lea    0xf1d(%rip),%rdi
call   1030 <printf@plt>
lea    0xf4a(%rip),%rdi
call   1030 <printf@plt>
lea    0xf77(%rip),%rdi
call   1030 <printf@plt>
lea    0xfa4(%rip),%rdi
call   1030 <printf@plt>
lea    0xfd1(%rip),%rdi
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
call   1030 <printf@plt>
lea    0xff2(%rip),%rdi
call   1030 <printf@plt>
lea    0x1058(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11ce <main+0xae>
mov    -0x8(%rbp),%edi
call   1040 <f_calculate@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11ae <main+0x8e>
lea    0xff3(%rip),%rdi
call   1030 <printf@plt>
lea    0x1006(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
lea    0xef4(%rip),%rdi
call   1040 <puts@plt>
lea    0x1000(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xf11(%rip),%rdi
call   1040 <puts@plt>
lea    0xf3d(%rip),%rdi
call   1040 <puts@plt>
lea    0xf69(%rip),%rdi
call   1040 <puts@plt>
lea    0xf95(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xff1(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
call   1050 <f_calculate@plt>
test   %eax,%eax
je     11b0 <main+0x80>
lea    0xffe(%rip),%rdi
call   1040 <puts@plt>
lea    0x1010(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [57 x i8] c"------------------------------------------------------|\0A\00"
@.str.1 = [57 x i8] c"|Integer -> Binary Converting Program |\0A\00"
@.str.2 = [57 x i8] c"| |\0A\00"
@.str.3 = [57 x i8] c"|Use: |\0A\00"
@.str.4 = [57 x i8] c"|Input a positive integer. |\0A\00"
@.str.5 = [57 x i8] c"|The result is the numbers binary array |\0A\00"
@.str.6 = [57 x i8] c"|in reverse order. |\0A\00"
@.str.7 = [57 x i8] c"|-----------------------------------------------------|\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [31 x i8] c"Thanks for using this program\0A\00"
@.str.10 = [28 x i8] c"EAP / exercise 1 / theme 3\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %14
14: ; preds = %17, %0
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* %2
%19 = call i32 @f_calculate(i32 %18)
store i32 %19, i32* %3
%20 = load i32, i32* %3
store i32 %20, i32* %2
br label %14
21: ; preds = %14
%22 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [56 x i8] c"------------------------------------------------------|\00"
@str.11 = [56 x i8] c"|Integer -> Binary Converting Program |\00"
@str.13 = [56 x i8] c"|Use: |\00"
@str.14 = [56 x i8] c"|Input a positive integer. |\00"
@str.15 = [56 x i8] c"|The result is the numbers binary array |\00"
@str.16 = [56 x i8] c"|in reverse order. |\00"
@str.17 = [56 x i8] c"| |\00"
@str.18 = [56 x i8] c"|-----------------------------------------------------|\00"
@str.19 = [30 x i8] c"Thanks for using this program\00"
@str.20 = [27 x i8] c"EAP / exercise 1 / theme 3\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.11, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.17, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.13, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.14, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.15, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.16, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.17, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.18, i64 0, i64 0))
%10 = tail call i32 @putchar(i32 10)
br label %11
11: ; preds = %0, %11
%12 = tail call i32 @f_calculate(i32 0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %11, label %14
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.19, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.20, i64 0, i64 0))
ret i32 0
}