#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 my_div(int, int);
int my_mod(int, int);
int my_udiv(int, int);
int my_umod(int, int);
int /*<<< orphan*/ puts(char *);
void foo(void) {
  if (my_div(5, -3) == -1) {
    puts("good 0");
  }
  if (my_mod(5, -3) == 2) {
    puts("good 1");
  }
  if (my_div(-5, 3) == -1) {
    puts("good 2");
  }
  if (my_mod(-5, 3) == -2) {
    puts("good 3");
  }
  if (my_div(-5, -3) == 1) {
    puts("good 4");
  }
  if (my_mod(-5, -3) == -2) {
    puts("good 5");
  }
  if (my_udiv(5, -3) == 0) {
    puts("good 6");
  }
  if (my_umod(5, -3) == 5) {
    puts("good 7");
  }
  if (my_udiv(-5, 3) == 0x55555553) {
    puts("good 8");
  }
  if (my_umod(-5, 3) == 2) {
    puts("good 9");
  }
  if (my_udiv(-5, -3) == 0) {
    puts("good 10");
  }
  if (my_umod(-5, -3) == -5) {
    puts("good 11");
  }
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    $0x5,%edi
mov    $0xfffffffd,%esi
call   1070 <my_div@plt>
cmp    $0xffffffff,%eax
jne    1178 <foo+0x28>
lea    0xe8d(%rip),%rdi
call   1040 <puts@plt>
mov    $0x5,%edi
mov    $0xfffffffd,%esi
call   1060 <my_mod@plt>
cmp    $0x2,%eax
jne    119c <foo+0x4c>
lea    0xe70(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0x3,%esi
call   1070 <my_div@plt>
cmp    $0xffffffff,%eax
jne    11c0 <foo+0x70>
lea    0xe53(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0x3,%esi
call   1060 <my_mod@plt>
cmp    $0xfffffffe,%eax
jne    11e4 <foo+0x94>
lea    0xe36(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0xfffffffd,%esi
call   1070 <my_div@plt>
cmp    $0x1,%eax
jne    1208 <foo+0xb8>
lea    0xe19(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0xfffffffd,%esi
call   1060 <my_mod@plt>
cmp    $0xfffffffe,%eax
jne    122c <foo+0xdc>
lea    0xdfc(%rip),%rdi
call   1040 <puts@plt>
mov    $0x5,%edi
mov    $0xfffffffd,%esi
call   1050 <my_udiv@plt>
cmp    $0x0,%eax
jne    1250 <foo+0x100>
lea    0xddf(%rip),%rdi
call   1040 <puts@plt>
mov    $0x5,%edi
mov    $0xfffffffd,%esi
call   1030 <my_umod@plt>
cmp    $0x5,%eax
jne    1274 <foo+0x124>
lea    0xdc2(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0x3,%esi
call   1050 <my_udiv@plt>
cmp    $0x55555553,%eax
jne    129a <foo+0x14a>
lea    0xda3(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0x3,%esi
call   1030 <my_umod@plt>
cmp    $0x2,%eax
jne    12be <foo+0x16e>
lea    0xd86(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0xfffffffd,%esi
call   1050 <my_udiv@plt>
cmp    $0x0,%eax
jne    12e2 <foo+0x192>
lea    0xd69(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0xfffffffd,%esi
call   1030 <my_umod@plt>
cmp    $0xfffffffb,%eax
jne    1306 <foo+0x1b6>
lea    0xd4d(%rip),%rdi
call   1040 <puts@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rax
mov    $0x5,%edi
mov    $0xfffffffd,%esi
call   1070 <my_div@plt>
cmp    $0xffffffff,%eax
jne    1171 <foo+0x21>
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
mov    $0x5,%edi
mov    $0xfffffffd,%esi
call   1060 <my_mod@plt>
cmp    $0x2,%eax
jne    1191 <foo+0x41>
lea    0xe7b(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0x3,%esi
call   1070 <my_div@plt>
cmp    $0xffffffff,%eax
jne    11b1 <foo+0x61>
lea    0xe62(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0x3,%esi
call   1060 <my_mod@plt>
cmp    $0xfffffffe,%eax
jne    11d1 <foo+0x81>
lea    0xe49(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0xfffffffd,%esi
call   1070 <my_div@plt>
cmp    $0x1,%eax
jne    11f1 <foo+0xa1>
lea    0xe30(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0xfffffffd,%esi
call   1060 <my_mod@plt>
cmp    $0xfffffffe,%eax
jne    1211 <foo+0xc1>
lea    0xe17(%rip),%rdi
call   1040 <puts@plt>
mov    $0x5,%edi
mov    $0xfffffffd,%esi
call   1050 <my_udiv@plt>
test   %eax,%eax
jne    1230 <foo+0xe0>
lea    0xdff(%rip),%rdi
call   1040 <puts@plt>
mov    $0x5,%edi
mov    $0xfffffffd,%esi
call   1030 <my_umod@plt>
cmp    $0x5,%eax
jne    1250 <foo+0x100>
lea    0xde6(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0x3,%esi
call   1050 <my_udiv@plt>
cmp    $0x55555553,%eax
jne    1272 <foo+0x122>
lea    0xdcb(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0x3,%esi
call   1030 <my_umod@plt>
cmp    $0x2,%eax
jne    1292 <foo+0x142>
lea    0xdb2(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0xfffffffd,%esi
call   1050 <my_udiv@plt>
test   %eax,%eax
jne    12b1 <foo+0x161>
lea    0xd9a(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffb,%edi
mov    $0xfffffffd,%esi
call   1030 <my_umod@plt>
cmp    $0xfffffffb,%eax
jne    12d2 <foo+0x182>
lea    0xd82(%rip),%rdi
pop    %rax
jmp    1040 <puts@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [7 x i8] c"good 0\00"
@.str.1 = [7 x i8] c"good 1\00"
@.str.2 = [7 x i8] c"good 2\00"
@.str.3 = [7 x i8] c"good 3\00"
@.str.4 = [7 x i8] c"good 4\00"
@.str.5 = [7 x i8] c"good 5\00"
@.str.6 = [7 x i8] c"good 6\00"
@.str.7 = [7 x i8] c"good 7\00"
@.str.8 = [7 x i8] c"good 8\00"
@.str.9 = [7 x i8] c"good 9\00"
@.str.10 = [8 x i8] c"good 10\00"
@.str.11 = [8 x i8] c"good 11\00"
define void @foo() {
%1 = call i32 @my_div(i32 5, i32 -3)
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = call i32 @my_mod(i32 5, i32 -3)
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = call i32 @my_div(i32 -5, i32 3)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = call i32 @my_mod(i32 -5, i32 3)
%17 = icmp eq i32 %16, -2
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
%21 = call i32 @my_div(i32 -5, i32 -3)
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %23, %20
%26 = call i32 @my_mod(i32 -5, i32 -3)
%27 = icmp eq i32 %26, -2
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
%31 = call i32 @my_udiv(i32 5, i32 -3)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %35
35: ; preds = %33, %30
%36 = call i32 @my_umod(i32 5, i32 -3)
%37 = icmp eq i32 %36, 5
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %40
40: ; preds = %38, %35
%41 = call i32 @my_udiv(i32 -5, i32 3)
%42 = icmp eq i32 %41, 1431655763
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %45
45: ; preds = %43, %40
%46 = call i32 @my_umod(i32 -5, i32 3)
%47 = icmp eq i32 %46, 2
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
%51 = call i32 @my_udiv(i32 -5, i32 -3)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
br label %55
55: ; preds = %53, %50
%56 = call i32 @my_umod(i32 -5, i32 -3)
%57 = icmp eq i32 %56, -5
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
br label %60
60: ; preds = %58, %55
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"good 0\00"
@.str.1 = [7 x i8] c"good 1\00"
@.str.2 = [7 x i8] c"good 2\00"
@.str.3 = [7 x i8] c"good 3\00"
@.str.4 = [7 x i8] c"good 4\00"
@.str.5 = [7 x i8] c"good 5\00"
@.str.6 = [7 x i8] c"good 6\00"
@.str.7 = [7 x i8] c"good 7\00"
@.str.8 = [7 x i8] c"good 8\00"
@.str.9 = [7 x i8] c"good 9\00"
@.str.10 = [8 x i8] c"good 10\00"
@.str.11 = [8 x i8] c"good 11\00"
define void @foo() {
%1 = tail call i32 @my_div(i32 5, i32 -3)
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = tail call i32 @my_mod(i32 5, i32 -3)
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = tail call i32 @my_div(i32 -5, i32 3)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = tail call i32 @my_mod(i32 -5, i32 3)
%17 = icmp eq i32 %16, -2
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
%21 = tail call i32 @my_div(i32 -5, i32 -3)
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %23, %20
%26 = tail call i32 @my_mod(i32 -5, i32 -3)
%27 = icmp eq i32 %26, -2
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
%31 = tail call i32 @my_udiv(i32 5, i32 -3)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %35
35: ; preds = %33, %30
%36 = tail call i32 @my_umod(i32 5, i32 -3)
%37 = icmp eq i32 %36, 5
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %40
40: ; preds = %38, %35
%41 = tail call i32 @my_udiv(i32 -5, i32 3)
%42 = icmp eq i32 %41, 1431655763
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %45
45: ; preds = %43, %40
%46 = tail call i32 @my_umod(i32 -5, i32 3)
%47 = icmp eq i32 %46, 2
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
%51 = tail call i32 @my_udiv(i32 -5, i32 -3)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
br label %55
55: ; preds = %53, %50
%56 = tail call i32 @my_umod(i32 -5, i32 -3)
%57 = icmp eq i32 %56, -5
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
br label %60
60: ; preds = %58, %55
ret void
}