#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 afunc(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, int *);
int foo(void) {
  int x = 0;
  int y = 0;
  scanf("%d %d", &x, &y);
  int z = x + y;
  int w = 1;
ifelse:
  printf("Ciao!\n");
  if (z > 0) {
    w += 1;
  } else {
    w -= 1;
  }
whileloop:
  while (x > 0) {
    w += 1;
    x -= 1;
  }
switchcase:
  switch (afunc(z, y)) {
  case 0:
    y = 0;
    break;
  case 5:
    y = 1;
    break;
  case 10:
    y = 2;
    break;
  default:
    y = 3;
    break;
  }
  if (z < 0) {
    goto ifelse;
  }
  return 0;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    118e <foo+0x5e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1197 <foo+0x67>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119c <foo+0x6c>
jmp    11a1 <foo+0x71>
cmpl   $0x0,-0x4(%rbp)
jle    11c2 <foo+0x92>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <foo+0x71>
jmp    11c7 <foo+0x97>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <afunc@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
test   %eax,%eax
je     1206 <foo+0xd6>
jmp    11e4 <foo+0xb4>
mov    -0x14(%rbp),%eax
sub    $0x5,%eax
je     1212 <foo+0xe2>
jmp    11f5 <foo+0xc5>
mov    -0x14(%rbp),%eax
sub    $0xa,%eax
je     121e <foo+0xee>
jmp    122a <foo+0xfa>
movl   $0x0,-0x8(%rbp)
jmp    1231 <foo+0x101>
movl   $0x1,-0x8(%rbp)
jmp    1231 <foo+0x101>
movl   $0x2,-0x8(%rbp)
jmp    1231 <foo+0x101>
movl   $0x3,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1240 <foo+0x110>
jmp    116a <foo+0x3a>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xeb6(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    (%rsp),%ebx
add    0x4(%rsp),%ebx
lea    0xea1(%rip),%r14
jmp    117b <foo+0x4b>
nopw   0x0(%rax,%rax,1)
movl   $0x1,(%rsp)
test   %ebx,%ebx
jns    11d9 <foo+0xa9>
mov    %r14,%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
jle    1192 <foo+0x62>
movl   $0x0,0x4(%rsp)
mov    (%rsp),%esi
mov    %ebx,%edi
call   1040 <afunc@plt>
cmp    $0xa,%eax
je     11c0 <foo+0x90>
cmp    $0x5,%eax
je     1170 <foo+0x40>
test   %eax,%eax
jne    11d0 <foo+0xa0>
movl   $0x0,(%rsp)
jmp    1177 <foo+0x47>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movl   $0x2,(%rsp)
jmp    1177 <foo+0x47>
nopl   0x0(%rax)
movl   $0x3,(%rsp)
jmp    1177 <foo+0x47>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [7 x i8] c"Ciao!\0A\00"
define i32 @foo() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = add nsw i32 %6, %7
store i32 %8, i32* %3
store i32 1, i32* %4
br label %9
9: ; preds = %41, %0
%10 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
br label %19
16: ; preds = %9
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 1
store i32 %18, i32* %4
br label %19
19: ; preds = %16, %13
br label %20
20: ; preds = %19
br label %21
21: ; preds = %24, %20
%22 = load i32, i32* %1
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
%27 = load i32, i32* %1
%28 = sub nsw i32 %27, 1
store i32 %28, i32* %1
br label %21
29: ; preds = %21
br label %30
30: ; preds = %29
%31 = load i32, i32* %3
%32 = load i32, i32* %2
%33 = call i32 @afunc(i32 %31, i32 %32)
switch i32 %33, label %37 [
i32 0, label %34
i32 5, label %35
i32 10, label %36
]
34: ; preds = %30
store i32 0, i32* %2
br label %38
35: ; preds = %30
store i32 1, i32* %2
br label %38
36: ; preds = %30
store i32 2, i32* %2
br label %38
37: ; preds = %30
store i32 3, i32* %2
br label %38
38: ; preds = %37, %36, %35, %34
%39 = load i32, i32* %3
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %38
br label %9
42: ; preds = %38
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@str = [6 x i8] c"Ciao!\00"
define i32 @foo() {
%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
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = add nsw i32 %7, %6
%9 = icmp slt i32 %8, 0
br label %10
10: ; preds = %22, %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 0, i32* %1
br label %15
15: ; preds = %14, %10
%16 = load i32, i32* %2
%17 = call i32 @afunc(i32 %8, i32 %16)
switch i32 %17, label %21 [
i32 0, label %18
i32 5, label %19
i32 10, label %20
]
18: ; preds = %15
store i32 0, i32* %2
br label %22
19: ; preds = %15
store i32 1, i32* %2
br label %22
20: ; preds = %15
store i32 2, i32* %2
br label %22
21: ; preds = %15
store i32 3, i32* %2
br label %22
22: ; preds = %21, %20, %19, %18
br i1 %9, label %10, label %23
23: ; preds = %22
ret i32 0
}