#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*/ cls();
int /*<<< orphan*/ hold();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ setAttr(int);
void cmain() {
  int i, j, k;
  int max = 300;
  setAttr(0xa1);
  cls();
  puts("in user2 code\n");
  for (i = 0; i < max; i++) {
    for (j = 0; j < max * max; j++) {
      for (k = 0; k < max; k++) {
      }
    }
    printf("%d hello, user2 console\n", i);
  }
  puts("\n\nUser2 code does not return\n");
  hold();
  puts("This message2 won't appear!\n");
}


x86 assembly (clang, -O0):
<cmain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x12c,-0x10(%rbp)
mov    $0xa1,%edi
call   1050 <setAttr@plt>
mov    $0x0,%al
call   1070 <cls@plt>
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11fe <cmain+0xae>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    11e1 <cmain+0x91>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ce <cmain+0x7e>
jmp    11c0 <cmain+0x70>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11af <cmain+0x5f>
jmp    11d3 <cmain+0x83>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1196 <cmain+0x46>
mov    -0x4(%rbp),%esi
lea    0xe24(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1183 <cmain+0x33>
lea    0xe23(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1030 <hold@plt>
lea    0xe2e(%rip),%rdi
call   1040 <puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmain>:
push   %r14
push   %rbx
push   %rax
mov    $0xa1,%edi
call   1050 <setAttr@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <cls@plt>
lea    0xe92(%rip),%rdi
call   1040 <puts@plt>
lea    0xe95(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <printf@plt>
add    $0x1,%ebx
cmp    $0x12c,%ebx
jne    1180 <cmain+0x30>
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <hold@plt>
lea    0xe97(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"in user2 code\0A\00"
@.str.1 = [25 x i8] c"%d hello, user2 console\0A\00"
@.str.2 = [30 x i8] c"\0A\0AUser2 code does not return\0A\00"
@.str.3 = [29 x i8] c"This message2 won't appear!\0A\00"
define void @cmain() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 300, i32* %4
%5 = call i32 @setAttr(i32 161)
%6 = call i32 (...) @cls()
%7 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %8
8: ; preds = %35, %0
%9 = load i32, i32* %1
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %38
12: ; preds = %8
store i32 0, i32* %2
br label %13
13: ; preds = %29, %12
%14 = load i32, i32* %2
%15 = load i32, i32* %4
%16 = load i32, i32* %4
%17 = mul nsw i32 %15, %16
%18 = icmp slt i32 %14, %17
br i1 %18, label %19, label %32
19: ; preds = %13
store i32 0, i32* %3
br label %20
20: ; preds = %25, %19
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %28
24: ; preds = %20
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %20
28: ; preds = %20
br label %29
29: ; preds = %28
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
br label %13
32: ; preds = %13
%33 = load i32, i32* %1
%34 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %32
%36 = load i32, i32* %1
%37 = add nsw i32 %36, 1
store i32 %37, i32* %1
br label %8
38: ; preds = %8
%39 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 (...) @hold()
%41 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"in user2 code\0A\00"
@.str.1 = [25 x i8] c"%d hello, user2 console\0A\00"
@.str.2 = [30 x i8] c"\0A\0AUser2 code does not return\0A\00"
@.str.3 = [29 x i8] c"This message2 won't appear!\0A\00"
define void @cmain() {
%1 = tail call i32 @setAttr(i32 161)
%2 = tail call i32 (...) @cls()
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %7, %4 ]
%6 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, 300
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 (...) @hold()
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
ret void
}