#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 add(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int a = 0, b = 0;
  while (a != 999 || b != 999) {
    printf("\nAdding a + b.For exit enter 999.\n");
    printf("Please enter a: ");
    scanf("%i", &a);
    printf("Please enter b: ");
    scanf("%i", &b);
    printf("a + b = %i\n", add(a, b));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x1,%al
cmpl   $0x3e7,-0x8(%rbp)
mov    %al,-0xd(%rbp)
jne    116c <main+0x3c>
cmpl   $0x3e7,-0xc(%rbp)
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    117c <main+0x4c>
jmp    11e6 <main+0xb6>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe95(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe77(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <add@plt>
mov    %eax,%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xe9f(%rip),%r15
lea    0xea9(%rip),%rbx
lea    0x4(%rsp),%r12
lea    0xea0(%rip),%r13
mov    %rsp,%rbp
lea    0xea7(%rip),%r14
xchg   %ax,%ax
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1030 <add@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x3e7,0x4(%rsp)
jne    1180 <main+0x40>
cmpl   $0x3e7,(%rsp)
jne    1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0AAdding a + b.For exit enter 999.\0A\00"
@.str.1 = [17 x i8] c"Please enter a: \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [17 x i8] c"Please enter b: \00"
@.str.4 = [12 x i8] c"a + b = %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %12, %0
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 999
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = load i32, i32* %3
%9 = icmp ne i32 %8, 999
br label %10
10: ; preds = %7, %4
%11 = phi i1 [ true, %4 ], [ %9, %7 ]
br i1 %11, label %12, label %22
12: ; preds = %10
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @add(i32 %18, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %20)
br label %4
22: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [17 x i8] c"Please enter a: \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [17 x i8] c"Please enter b: \00"
@.str.4 = [12 x i8] c"a + b = %i\0A\00"
@str = [34 x i8] c"\0AAdding a + b.For exit enter 999.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %0, %5
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = call i32 @add(i32 %11, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
%16 = icmp ne i32 %15, 999
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, 999
%19 = select i1 %16, i1 true, i1 %18
br i1 %19, label %5, label %20
20: ; preds = %5
ret i32 0
}