#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 cube(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void do_cube(int num) {
  if (num > 10 || num < 1) {
    fprintf(stderr, "ERROR: Out of Range\n");
  } else {
    for (; num > 0; num--) {
      fprintf(stdout, "The cube of %2d is %4d\n", num, cube(num));
    }
  }
}


x86 assembly (clang, -O0):
<do_cube>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jg     113f <do_cube+0x1f>
cmpl   $0x1,-0x4(%rbp)
jge    115b <do_cube+0x3b>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xeb1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11ad <do_cube+0x8d>
jmp    1160 <do_cube+0x40>
cmpl   $0x0,-0x4(%rbp)
jle    11a8 <do_cube+0x88>
mov    0x2e67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <cube@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    %eax,%ecx
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1160 <do_cube+0x40>
jmp    11ad <do_cube+0x8d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_cube>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    -0xb(%rbx),%eax
cmp    $0xfffffff6,%eax
jae    1152 <do_cube+0x32>
mov    0x2ea8(%rip),%rax
mov    (%rax),%edi
lea    0xebf(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>
mov    0x2e7f(%rip),%r15
lea    0xeb5(%rip),%r14
mov    (%r15),%ebp
mov    %ebx,%edi
call   1040 <cube@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x1(%rbx),%eax
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     1160 <do_cube+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"ERROR: Out of Range\0A\00"
@stdout = global i32 0
@.str.1 = [24 x i8] c"The cube of %2d is %4d\0A\00"
define void @do_cube(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sgt i32 %3, 10
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %11
8: ; preds = %5, %1
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %25
11: ; preds = %5
br label %12
12: ; preds = %21, %11
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load i32, i32* @stdout
%17 = load i32, i32* %2
%18 = load i32, i32* %2
%19 = call i32 @cube(i32 %18)
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %19)
br label %21
21: ; preds = %15
%22 = load i32, i32* %2
%23 = add nsw i32 %22, -1
store i32 %23, i32* %2
br label %12
24: ; preds = %12
br label %25
25: ; preds = %24, %8
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"ERROR: Out of Range\0A\00"
@stdout = global i32 0
@.str.1 = [24 x i8] c"The cube of %2d is %4d\0A\00"
define void @do_cube(i32 %0) {
%2 = add i32 %0, -11
%3 = icmp ult i32 %2, -10
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %14
7: ; preds = %1, %7
%8 = phi i32 [ %12, %7 ], [ %0, %1 ]
%9 = load i32, i32* @stdout
%10 = tail call i32 @cube(i32 %8)
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %10)
%12 = add nsw i32 %8, -1
%13 = icmp ugt i32 %8, 1
br i1 %13, label %7, label %14
14: ; preds = %7, %4
ret void
}