#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 *, long, long);
int /*<<< orphan*/ stderr;
long pow_fun_long(long a, long b) {
  long r = 1;
  int i;
  if (b < 0) {
    fprintf(stderr, "Negative exponent in function pow_fun_(): %ld `pow` %ld",
            a, b);
    exit(1);
  }
  for (i = 0; i < b; ++i)
    r *= a;
  return r;
}


x86 assembly (clang, -O0):
<pow_fun_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x1,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    116a <pow_fun_long+0x4a>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xea5(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    119a <pow_fun_long+0x7a>
mov    -0x8(%rbp),%rax
imul   -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1171 <pow_fun_long+0x51>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pow_fun_long>:
mov    %rsi,%rcx
mov    %rdi,%rdx
test   %rsi,%rsi
js     119b <pow_fun_long+0x7b>
je     1143 <pow_fun_long+0x23>
lea    -0x1(%rcx),%rax
mov    %ecx,%esi
and    $0x7,%esi
cmp    $0x7,%rax
jae    1149 <pow_fun_long+0x29>
mov    $0x1,%eax
jmp    1186 <pow_fun_long+0x66>
mov    $0x1,%eax
ret
and    $0xfffffffffffffff8,%rcx
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
imul   %rdx,%rax
imul   %rdx,%rax
imul   %rdx,%rax
imul   %rdx,%rax
imul   %rdx,%rax
imul   %rdx,%rax
imul   %rdx,%rax
imul   %rdx,%rax
add    $0xfffffffffffffff8,%rcx
jne    1160 <pow_fun_long+0x40>
test   %rsi,%rsi
je     119a <pow_fun_long+0x7a>
nopl   0x0(%rax,%rax,1)
imul   %rdx,%rax
add    $0xffffffffffffffff,%rsi
jne    1190 <pow_fun_long+0x70>
ret
push   %rax
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [56 x i8] c"Negative exponent in function pow_fun_(): %ld `pow` %ld\00"
define i64 @pow_fun_long(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
store i64 %0, i64* %3
store i64 %1, i64* %4
store i64 1, i64* %5
%7 = load i64, i64* %4
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i64, i64* %3
%12 = load i64, i64* %4
%13 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i64 %11, i64 %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
store i32 0, i32* %6
br label %16
16: ; preds = %25, %15
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = load i64, i64* %4
%20 = icmp slt i64 %18, %19
br i1 %20, label %21, label %28
21: ; preds = %16
%22 = load i64, i64* %3
%23 = load i64, i64* %5
%24 = mul nsw i64 %23, %22
store i64 %24, i64* %5
br label %25
25: ; preds = %21
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %16
28: ; preds = %16
%29 = load i64, i64* %5
ret i64 %29
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [56 x i8] c"Negative exponent in function pow_fun_(): %ld `pow` %ld\00"
define i64 @pow_fun_long(i64 %0, i64 %1) {
%3 = icmp slt i64 %1, 0
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = icmp eq i64 %1, 0
br i1 %5, label %39, label %6
6: ; preds = %4
%7 = add i64 %1, -1
%8 = and i64 %1, 7
%9 = icmp ult i64 %7, 7
br i1 %9, label %29, label %10
10: ; preds = %6
%11 = and i64 %1, -8
br label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i64 %0, i64 %1)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %16, %10
%17 = phi i64 [ 1, %10 ], [ %26, %16 ]
%18 = phi i64 [ 0, %10 ], [ %27, %16 ]
%19 = mul nsw i64 %17, %0
%20 = mul nsw i64 %19, %0
%21 = mul nsw i64 %20, %0
%22 = mul nsw i64 %21, %0
%23 = mul nsw i64 %22, %0
%24 = mul nsw i64 %23, %0
%25 = mul nsw i64 %24, %0
%26 = mul nsw i64 %25, %0
%27 = add i64 %18, 8
%28 = icmp eq i64 %27, %11
br i1 %28, label %29, label %16
29: ; preds = %16, %6
%30 = phi i64 [ undef, %6 ], [ %26, %16 ]
%31 = phi i64 [ 1, %6 ], [ %26, %16 ]
%32 = icmp eq i64 %8, 0
br i1 %32, label %39, label %33
33: ; preds = %29, %33
%34 = phi i64 [ %36, %33 ], [ %31, %29 ]
%35 = phi i64 [ %37, %33 ], [ 0, %29 ]
%36 = mul nsw i64 %34, %0
%37 = add i64 %35, 1
%38 = icmp eq i64 %37, %8
br i1 %38, label %39, label %33
39: ; preds = %29, %33, %4
%40 = phi i64 [ 1, %4 ], [ %30, %29 ], [ %36, %33 ]
ret i64 %40
}