#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*/ init();
int min_trg_from(int, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int h, i;
  int sum;
  int min_sum = 0;
  init();
  for (h = 0; h < 1000; h++)
    for (i = 0; i <= h; i++) {
      sum = min_trg_from(h, i);
      if (sum < min_sum)
        min_sum = sum;
    }
  printf("%d", min_sum);
}


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)
movl   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1050 <init@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jge    11c1 <main+0x91>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11ae <main+0x7e>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <min_trg_from@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    119b <main+0x6b>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11a0 <main+0x70>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116f <main+0x3f>
jmp    11b3 <main+0x83>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <main+0x2b>
mov    -0x20(%rbp),%esi
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <init@plt>
mov    $0x1,%r15d
xor    %r14d,%r14d
nopl   0x0(%rax)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14d,%edi
mov    %ebp,%esi
call   1040 <min_trg_from@plt>
cmp    %ebx,%eax
cmovl  %eax,%ebx
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1160 <main+0x30>
add    $0x1,%r14d
add    $0x1,%r15d
cmp    $0x3e8,%r14d
jne    1150 <main+0x20>
lea    0xe71(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\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
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%10 = call i32 (...) @init()
store i32 0, i32* %6
br label %11
11: ; preds = %33, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 1000
br i1 %13, label %14, label %36
14: ; preds = %11
store i32 0, i32* %7
br label %15
15: ; preds = %29, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %32
19: ; preds = %15
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = call i32 @min_trg_from(i32 %20, i32 %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = load i32, i32* %8
store i32 %27, i32* %9
br label %28
28: ; preds = %26, %19
br label %29
29: ; preds = %28
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %15
32: ; preds = %15
br label %33
33: ; preds = %32
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %11
36: ; preds = %11
%37 = load i32, i32* %9
%38 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @init()
br label %4
4: ; preds = %2, %16
%5 = phi i32 [ 1, %2 ], [ %18, %16 ]
%6 = phi i32 [ 0, %2 ], [ %13, %16 ]
%7 = phi i32 [ 0, %2 ], [ %17, %16 ]
br label %8
8: ; preds = %4, %8
%9 = phi i32 [ %6, %4 ], [ %13, %8 ]
%10 = phi i32 [ 0, %4 ], [ %14, %8 ]
%11 = tail call i32 @min_trg_from(i32 %7, i32 %10)
%12 = icmp slt i32 %11, %9
%13 = select i1 %12, i32 %11, i32 %9
%14 = add nuw nsw i32 %10, 1
%15 = icmp eq i32 %14, %5
br i1 %15, label %16, label %8
16: ; preds = %8
%17 = add nuw nsw i32 %7, 1
%18 = add nuw nsw i32 %5, 1
%19 = icmp eq i32 %17, 1000
br i1 %19, label %20, label %4
20: ; preds = %16
%21 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
ret i32 0
}