#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*/ init_uart();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  char c;
  int a, b;
  init_uart();
  printf("hello, world\n\r");
  while (1) {
    printf("please enter two number: \n\r");
    scanf("%d %d", &a, &b);
    printf("\n\r");
    printf("the sum is: %d\n\r", a + b);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <init_uart@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <scanf@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
add    -0x10(%rbp),%esi
mov    %esi,-0x14(%rbp)
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1154 <main+0x24>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <init_uart@plt>
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb8(%rip),%r14
lea    0xecd(%rip),%r15
lea    0x4(%rsp),%r12
mov    %rsp,%r13
lea    0xebb(%rip),%rbx
lea    0xebd(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <scanf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%esi
add    0x4(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1180 <main+0x50>

LLVM IR (-O0):
@.str = [15 x i8] c"hello, world\0A\0D\00"
@.str.1 = [28 x i8] c"please enter two number: \0A\0D\00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.3 = [3 x i8] c"\0A\0D\00"
@.str.4 = [17 x i8] c"the sum is: %d\0A\0D\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @init_uart()
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %0, %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %3, i32* %4)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = add nsw i32 %11, %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %13)
br label %7
}

LLVM IR (-O2):
@.str = [15 x i8] c"hello, world\0A\0D\00"
@.str.1 = [28 x i8] c"please enter two number: \0A\0D\00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.3 = [3 x i8] c"\0A\0D\00"
@.str.4 = [17 x i8] c"the sum is: %d\0A\0D\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (...) @init_uart()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %7, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = add nsw i32 %12, %11
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %13)
br label %7
}