#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 func_unroll1();
int func_unroll2();
int func_unroll4();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int size_unroll1, size_unroll2, size_unroll4;
  size_unroll1 = func_unroll1();
  size_unroll2 = func_unroll2();
  size_unroll4 = func_unroll4();
  if ((size_unroll1 == 0) || (size_unroll2 == 0) || (size_unroll4 == 0)) {
    printf("Not functional, or could not compute loop size. Error.\n");
    return 1;
  }
  if ((size_unroll1 >= size_unroll2) || (size_unroll2 >= size_unroll4)) {
    printf("loop size: unroll=1 size=%d, unroll=2 size=%d, unroll=4 size=%d\n",
           size_unroll1, size_unroll2, size_unroll4);
    printf("--param max-unroll-times not used. Error.\n");
    return 1;
  }
  printf("Success\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <func_unroll1@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <func_unroll2@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <func_unroll4@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1192 <main+0x52>
cmpl   $0x0,-0x18(%rbp)
je     1192 <main+0x52>
cmpl   $0x0,-0x1c(%rbp)
jne    11ac <main+0x6c>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    120a <main+0xca>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c4 <main+0x84>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     11f5 <main+0xb5>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    120a <main+0xca>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1070 <func_unroll1@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <func_unroll2@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <func_unroll4@plt>
mov    $0x1,%r14d
lea    0xef9(%rip),%rdi
test   %ebp,%ebp
je     11b5 <main+0x65>
test   %ebx,%ebx
je     11b5 <main+0x65>
test   %eax,%eax
je     11b5 <main+0x65>
cmp    %ebx,%ebp
jge    119a <main+0x4a>
cmp    %eax,%ebx
jge    119a <main+0x4a>
xor    %r14d,%r14d
lea    0xea9(%rip),%rdi
jmp    11b5 <main+0x65>
lea    0xe5f(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"Not functional, or could not compute loop size. Error.\0A\00"
@.str.1 = [65 x i8] c"loop size: unroll=1 size=%d, unroll=2 size=%d, unroll=4 size=%d\0A\00"
@.str.2 = [43 x i8] c"--param max-unroll-times not used. Error.\0A\00"
@.str.3 = [9 x i8] c"Success\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (...) @func_unroll1()
store i32 %9, i32* %6
%10 = call i32 (...) @func_unroll2()
store i32 %10, i32* %7
%11 = call i32 (...) @func_unroll4()
store i32 %11, i32* %8
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %2
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17, %14, %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %38
22: ; preds = %17
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = icmp sge i32 %23, %24
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load i32, i32* %7
%28 = load i32, i32* %8
%29 = icmp sge i32 %27, %28
br i1 %29, label %30, label %36
30: ; preds = %26, %22
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %38
36: ; preds = %26
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %38
38: ; preds = %36, %30, %20
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str.1 = [65 x i8] c"loop size: unroll=1 size=%d, unroll=2 size=%d, unroll=4 size=%d\0A\00"
@str = [8 x i8] c"Success\00"
@str.4 = [42 x i8] c"--param max-unroll-times not used. Error.\00"
@str.5 = [55 x i8] c"Not functional, or could not compute loop size. Error.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @func_unroll1()
%4 = tail call i32 (...) @func_unroll2()
%5 = tail call i32 (...) @func_unroll4()
%6 = icmp eq i32 %3, 0
%7 = icmp eq i32 %4, 0
%8 = select i1 %6, i1 true, i1 %7
%9 = icmp eq i32 %5, 0
%10 = select i1 %8, i1 true, i1 %9
br i1 %10, label %17, label %11
11: ; preds = %2
%12 = icmp slt i32 %3, %4
%13 = icmp slt i32 %4, %5
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %4, i32 %5)
br label %17
17: ; preds = %11, %2, %15
%18 = phi i8* [ getelementptr inbounds ([42 x i8], [42 x i8]* @str.4, i64 0, i64 0), %15 ], [ getelementptr inbounds ([55 x i8], [55 x i8]* @str.5, i64 0, i64 0), %2 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0), %11 ]
%19 = phi i32 [ 1, %15 ], [ 1, %2 ], [ 0, %11 ]
%20 = tail call i32 @puts(i8* dereferenceable(1) %18)
ret i32 %19
}