#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 fun(char x) {
  int y = 10;
  int i = 0;
  printf("BEFORE YCF_YIELD()\n");
  y = y + x;
  for (i = 0; i < 100; i++) {
    printf("ITER %d\n", i);
    y = y + x;
    ;
  }
  printf("AFTER YCF_YIELD()\n");
  y = y * 3;
  return y;
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
movsbl -0x1(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    1182 <fun+0x72>
mov    -0xc(%rbp),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
movsbl -0x1(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <fun+0x3d>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
imul   $0x3,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
lea    0xec6(%rip),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x64,%ebp
jne    1140 <fun+0x20>
movsbl %r14b,%ebx
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
imul   $0x12f,%ebx,%eax
add    $0x1e,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [9 x i8] c"ITER %d\0A\00"
@str = [19 x i8] c"BEFORE YCF_YIELD()\00"
@str.3 = [18 x i8] c"AFTER YCF_YIELD()\00"
define i32 @fun(i8 signext %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %3
3: ; preds = %1, %3
%4 = phi i32 [ 0, %1 ], [ %6, %3 ]
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = add nuw nsw i32 %4, 1
%7 = icmp eq i32 %6, 100
br i1 %7, label %8, label %3
8: ; preds = %3
%9 = sext i8 %0 to i32
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.3, i64 0, i64 0))
%11 = mul nsw i32 %9, 303
%12 = add nsw i32 %11, 30
ret i32 %12
}