#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
long super(int i) {
  long power;
  int k;
  if (i <= 0) {
    fprintf(stderr, "bad argument super(%d)\n", i);
    exit(1);
  }
  k = 1;
  power = 2;
  while (power < (i + 1)) {
    k += 1;
    power *= 2;
  }
  if (power == (i + 1))
    return (power / 2);
  return (super(i - (power / 2) + 1));
}


x86 assembly (clang, -O0):
<super>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     1167 <super+0x37>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xea8(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x1,-0x1c(%rbp)
movq   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jge    11a6 <super+0x76>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1176 <super+0x46>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jne    11d3 <super+0xa3>
mov    -0x18(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
jmp    1202 <super+0xd2>
movslq -0xc(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1030 <super@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<super>:
mov    %edi,%edx
test   %edi,%edi
jle    1156 <super+0x36>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%edx
movslq %edx,%rax
mov    $0x2,%esi
nopl   0x0(%rax,%rax,1)
mov    %rsi,%rcx
add    %rsi,%rsi
cmp    %rax,%rcx
jl     1140 <super+0x20>
je     1176 <super+0x56>
shr    %rcx
sub    %ecx,%edx
test   %edx,%edx
jg     1130 <super+0x10>
push   %rax
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
shr    %rax
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"bad argument super(%d)\0A\00"
define i64 @super(i32 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = load i32, i32* %3
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %1
store i32 1, i32* %5
store i64 2, i64* %4
br label %14
14: ; preds = %20, %13
%15 = load i64, i64* %4
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %15, %18
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
%23 = load i64, i64* %4
%24 = mul nsw i64 %23, 2
store i64 %24, i64* %4
br label %14
25: ; preds = %14
%26 = load i64, i64* %4
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = icmp eq i64 %26, %29
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = load i64, i64* %4
%33 = sdiv i64 %32, 2
store i64 %33, i64* %2
br label %43
34: ; preds = %25
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = load i64, i64* %4
%38 = sdiv i64 %37, 2
%39 = sub nsw i64 %36, %38
%40 = add nsw i64 %39, 1
%41 = trunc i64 %40 to i32
%42 = call i64 @super(i32 %41)
store i64 %42, i64* %2
br label %43
43: ; preds = %34, %31
%44 = load i64, i64* %2
ret i64 %44
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"bad argument super(%d)\0A\00"
define i64 @super(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %7, label %3
3: ; preds = %1, %20
%4 = phi i32 [ %23, %20 ], [ %0, %1 ]
%5 = add nuw i32 %4, 1
%6 = sext i32 %5 to i64
br label %12
7: ; preds = %20, %1
%8 = phi i32 [ %0, %1 ], [ %23, %20 ]
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %8)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %12, %3
%13 = phi i64 [ %15, %12 ], [ 2, %3 ]
%14 = icmp slt i64 %13, %6
%15 = shl nsw i64 %13, 1
br i1 %14, label %12, label %16
16: ; preds = %12
%17 = icmp eq i64 %13, %6
br i1 %17, label %18, label %20
18: ; preds = %16
%19 = lshr exact i64 %6, 1
ret i64 %19
20: ; preds = %16
%21 = lshr exact i64 %13, 1
%22 = trunc i64 %21 to i32
%23 = sub i32 %5, %22
%24 = icmp slt i32 %23, 1
br i1 %24, label %7, label %3
}