#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*/ scanf(char *, int *);
int get_input(void) {
  int input;
  do {
    printf("Enter a number that is greater than 0 > ");
    scanf("%d", &input);
    if (input <= 0) {
      printf("Invalid input\n");
    }
  } while (input <= 0);
  printf("The number you entered was %d\n", input);
  return input;
}


x86 assembly (clang, -O0):
<get_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
jg     115e <get_input+0x3e>
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1163 <get_input+0x43>
cmpl   $0x0,-0x4(%rbp)
jle    1128 <get_input+0x8>
mov    -0x4(%rbp),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_input>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%r14
lea    0xee3(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xef9(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jg     118d <get_input+0x5d>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    1160 <get_input+0x30>
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Enter a number that is greater than 0 > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"Invalid input\0A\00"
@.str.3 = [31 x i8] c"The number you entered was %d\0A\00"
define i32 @get_input() {
%1 = alloca i32
br label %2
2: ; preds = %10, %0
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sle i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %2
br label %10
10: ; preds = %9
%11 = load i32, i32* %1
%12 = icmp sle i32 %11, 0
br i1 %12, label %2, label %13
13: ; preds = %10
%14 = load i32, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@.str = [41 x i8] c"Enter a number that is greater than 0 > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [31 x i8] c"The number you entered was %d\0A\00"
@str = [14 x i8] c"Invalid input\00"
define i32 @get_input() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %8, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 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 ([14 x i8], [14 x i8]* @str, 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 = phi i32 [ %10, %8 ], [ %6, %3 ]
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
ret i32 %15
}