#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 */
long long pow(int, int);
long long int rem(long long int a, long long int b) {
  if (b == 0) {
    return a;
  } else if ((a == (-pow(2, 4 - 1))) & (b == -1)) {
    return 0;
  } else {
    return a % b;
  }
}


x86 assembly (clang, -O0):
<rem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1138 <rem+0x28>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119a <rem+0x8a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x2,%edi
mov    $0x3,%esi
call   1030 <pow@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
xor    %ecx,%ecx
sub    %rdx,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
cmpq   $0xffffffffffffffff,-0x18(%rbp)
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     118c <rem+0x7c>
movq   $0x0,-0x8(%rbp)
jmp    119a <rem+0x8a>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
mov    %rdx,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rem>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rsi,%rsi
je     1164 <rem+0x54>
mov    %rsi,%rbx
mov    $0x2,%edi
mov    $0x3,%esi
call   1030 <pow@plt>
cmp    $0xffffffffffffffff,%rbx
jne    1141 <rem+0x31>
neg    %rax
cmp    %r14,%rax
jne    1141 <rem+0x31>
xor    %r14d,%r14d
jmp    1164 <rem+0x54>
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     115a <rem+0x4a>
mov    %r14,%rax
cqto
idiv   %rbx
mov    %rdx,%r14
jmp    1164 <rem+0x54>
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
mov    %edx,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @rem(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
%6 = load i64, i64* %5
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = load i64, i64* %4
store i64 %9, i64* %3
br label %26
10: ; preds = %2
%11 = load i64, i64* %4
%12 = call i64 @pow(i32 2, i32 3)
%13 = sub nsw i64 0, %12
%14 = icmp eq i64 %11, %13
%15 = zext i1 %14 to i32
%16 = load i64, i64* %5
%17 = icmp eq i64 %16, -1
%18 = zext i1 %17 to i32
%19 = and i32 %15, %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %10
store i64 0, i64* %3
br label %26
22: ; preds = %10
%23 = load i64, i64* %4
%24 = load i64, i64* %5
%25 = srem i64 %23, %24
store i64 %25, i64* %3
br label %26
26: ; preds = %22, %21, %8
%27 = load i64, i64* %3
ret i64 %27
}

LLVM IR (-O2):
define i64 @rem(i64 %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = tail call i64 @pow(i32 2, i32 3)
%6 = sub nsw i64 0, %5
%7 = icmp eq i64 %6, %0
%8 = icmp eq i64 %1, -1
%9 = and i1 %8, %7
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = srem i64 %0, %1
br label %12
12: ; preds = %4, %2, %10
%13 = phi i64 [ %11, %10 ], [ %0, %2 ], [ 0, %4 ]
ret i64 %13
}