#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int fun(char x) {
  int y = 10;
  if (0) {
    ;
    printf("y=%d\n", y);
    y = 42;
  };
  if (0) {
    ;
    printf("I returned y=%d\n", y);
  };
  if (0) {
    ;
    printf("I got destroyed or returned y=%d\n", y);
  };
  if (0) {
    ;
    x = 9;
  };
  if (0) {
    if (0) {
      ;
      {
        int z = 10;
        printf("y=%d z=%d\n", y, z);
      }
    };
  }
  if (y != 10 || x != 1) {
    if (0) {
      ;
      printf("y=%d x=%d\n", y, x);
      x = x * 2;
      printf("y=%d x=%d\n", y, x);
    };
    if (0) {
      ;
      printf("y=%d x=%d\n", y, x);
      x = x / 2;
      printf("y=%d x=%d\n", y, x);
    };
    printf("ERROR BEFORE YIELD\n");
    exit(1);
  };
  if (y != 42 || x != 9) {
    printf("ERROR AFTER YIELD\n");
    exit(1);
  }
  printf("SUCCESS\n");
  return x;
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0xa,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jne    114c <fun+0x2c>
movsbl -0x1(%rbp),%eax
cmp    $0x1,%eax
je     1164 <fun+0x44>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
cmpl   $0x2a,-0x8(%rbp)
jne    117b <fun+0x5b>
movsbl -0x1(%rbp),%eax
cmp    $0x9,%eax
je     1193 <fun+0x73>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rax
cmp    $0x1,%dil
jne    1130 <fun+0x10>
lea    0xed2(%rip),%rdi
jmp    1137 <fun+0x17>
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"ERROR BEFORE YIELD\0A\00"
@.str.1 = [19 x i8] c"ERROR AFTER YIELD\0A\00"
@.str.2 = [9 x i8] c"SUCCESS\0A\00"
define i32 @fun(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
store i32 10, i32* %3
%4 = load i32, i32* %3
%5 = icmp ne i32 %4, 10
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %6, %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %6
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 42
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 9
br i1 %19, label %20, label %23
20: ; preds = %16, %13
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %16
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%25 = load i8, i8* %2
%26 = sext i8 %25 to i32
ret i32 %26
}

LLVM IR (-O2):
@str = [18 x i8] c"ERROR AFTER YIELD\00"
@str.3 = [19 x i8] c"ERROR BEFORE YIELD\00"
define i32 @fun(i8 signext %0) {
%2 = icmp eq i8 %0, 1
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.3, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
}