#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*/ printf(char *, ...);
int /*<<< orphan*/ recursedigit(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a;
  a = 0;
  while (0 >= a) {
    printf("Give me a number: ");
    scanf("%d", &a);
    if (0 >= a) {
      printf("I need a positive integer.\n");
    }
  }
  printf("The binary representation of: ");
  printf("%d\n", a);
  printf("is: ");
  recursedigit(a);
  printf("\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jl     118d <main+0x5d>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jl     1188 <main+0x58>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1146 <main+0x16>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1030 <recursedigit@plt>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xea9(%rip),%r14
lea    0xeb5(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xed4(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jg     119b <main+0x5b>
mov    %r12,%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
jle    1170 <main+0x30>
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%edi
call   1040 <recursedigit@plt>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Give me a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"I need a positive integer.\0A\00"
@.str.3 = [31 x i8] c"The binary representation of: \00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.5 = [5 x i8] c"is: \00"
@.str.6 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %13, %0
%4 = load i32, i32* %2
%5 = icmp sge i32 0, %4
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = icmp sge i32 0, %9
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
br label %3
14: ; preds = %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%19 = load i32, i32* %2
%20 = call i32 @recursedigit(i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [19 x i8] c"Give me a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [31 x i8] c"The binary representation of: \00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.5 = [5 x i8] c"is: \00"
@str = [2 x i8] c"\0A\00"
@str.7 = [27 x i8] c"I need a positive integer.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %0, %8
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 1
br i1 %11, label %3, label %12
12: ; preds = %3, %8
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%14 = load i32, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%17 = load i32, i32* %1
%18 = call i32 @recursedigit(i32 %17)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}