#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int f(int, int, int, int, int);
int g(int, int, int, int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(void) {
  int i;
  int a, b, c, d, e;
  int v1, v2;
  srand(time(0));
  for (i = 0; i < 100; i++) {
    a = rand() % 5000 - 1000;
    b = rand() % 5000 - 1000;
    c = rand() % 5000 - 1000;
    d = rand() % 5000 - 1000;
    e = rand() % 5000 - 1000;
    printf("%d %d %d %d %d\n", a, b, c, d, e);
    v1 = f(a, b, c, d, e);
    printf("%d\n", v1);
    v2 = g(a, b, c, d, e);
    printf("%d\n", v2);
    if (v1 != v2) {
      return EXIT_FAILURE;
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    12a7 <main+0x147>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x1388,%ecx
cltd
idiv   %ecx
sub    $0x3e8,%edx
mov    %edx,-0xc(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x1388,%ecx
cltd
idiv   %ecx
sub    $0x3e8,%edx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x1388,%ecx
cltd
idiv   %ecx
sub    $0x3e8,%edx
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x1388,%ecx
cltd
idiv   %ecx
sub    $0x3e8,%edx
mov    %edx,-0x18(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x1388,%ecx
cltd
idiv   %ecx
sub    $0x3e8,%edx
mov    %edx,-0x1c(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1030 <f@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1070 <g@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     1294 <main+0x134>
mov    0x2d56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12b3 <main+0x153>
jmp    1299 <main+0x139>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1184 <main+0x24>
mov    0x2d2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x64,%eax
xchg   %ax,%ax
mov    %eax,(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2b,%rcx
add    %edx,%ecx
imul   $0x1388,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0xfffffc18,%ebp
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2b,%rcx
add    %edx,%ecx
imul   $0x1388,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0xfffffc18,%ebx
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2b,%rcx
add    %edx,%ecx
imul   $0x1388,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r15d
add    $0xfffffc18,%r15d
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2b,%rcx
add    %edx,%ecx
imul   $0x1388,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r13d
add    $0xfffffc18,%r13d
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2b,%rcx
add    %edx,%ecx
imul   $0x1388,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r14d
add    $0xfffffc18,%r14d
lea    0xd8a(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r15d,0x4(%rsp)
mov    %r15d,%ecx
mov    %r13d,%r8d
mov    %r14d,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r13d,%ecx
mov    %r14d,%r8d
call   1030 <f@plt>
mov    %eax,%r15d
lea    0xd61(%rip),%r12
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    0x4(%rsp),%edx
mov    %r13d,%ecx
mov    %r14d,%r8d
call   1070 <g@plt>
mov    %eax,%ebx
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %ebx,%r15d
jne    12f2 <main+0x192>
mov    (%rsp),%eax
add    $0xffffffff,%eax
jne    1180 <main+0x20>
mov    0x2ce8(%rip),%rax
jmp    12f9 <main+0x199>
mov    0x2ce7(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%d %d %d %d %d\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 @time(i32 0)
%11 = call i32 @srand(i32 %10)
store i32 0, i32* %2
br label %12
12: ; preds = %59, %0
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 100
br i1 %14, label %15, label %62
15: ; preds = %12
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 5000
%18 = sub nsw i32 %17, 1000
store i32 %18, i32* %3
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 5000
%21 = sub nsw i32 %20, 1000
store i32 %21, i32* %4
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 5000
%24 = sub nsw i32 %23, 1000
store i32 %24, i32* %5
%25 = call i32 (...) @rand()
%26 = srem i32 %25, 5000
%27 = sub nsw i32 %26, 1000
store i32 %27, i32* %6
%28 = call i32 (...) @rand()
%29 = srem i32 %28, 5000
%30 = sub nsw i32 %29, 1000
store i32 %30, i32* %7
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = load i32, i32* %7
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %31, i32 %32, i32 %33, i32 %34, i32 %35)
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = call i32 @f(i32 %37, i32 %38, i32 %39, i32 %40, i32 %41)
store i32 %42, i32* %8
%43 = load i32, i32* %8
%44 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %3
%46 = load i32, i32* %4
%47 = load i32, i32* %5
%48 = load i32, i32* %6
%49 = load i32, i32* %7
%50 = call i32 @g(i32 %45, i32 %46, i32 %47, i32 %48, i32 %49)
store i32 %50, i32* %9
%51 = load i32, i32* %9
%52 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %8
%54 = load i32, i32* %9
%55 = icmp ne i32 %53, %54
br i1 %55, label %56, label %58
56: ; preds = %15
%57 = load i32, i32* @EXIT_FAILURE
store i32 %57, i32* %1
br label %64
58: ; preds = %15
br label %59
59: ; preds = %58
%60 = load i32, i32* %2
%61 = add nsw i32 %60, 1
store i32 %61, i32* %2
br label %12
62: ; preds = %12
%63 = load i32, i32* @EXIT_SUCCESS
store i32 %63, i32* %1
br label %64
64: ; preds = %62, %56
%65 = load i32, i32* %1
ret i32 %65
}

LLVM IR (-O2):
@.str = [16 x i8] c"%d %d %d %d %d\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 @time(i32 0)
%2 = tail call i32 @srand(i32 %1)
br label %6
3: ; preds = %6
%4 = add nuw nsw i32 %7, 1
%5 = icmp eq i32 %4, 100
br i1 %5, label %29, label %6
6: ; preds = %0, %3
%7 = phi i32 [ 0, %0 ], [ %4, %3 ]
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 5000
%10 = add nsw i32 %9, -1000
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 5000
%13 = add nsw i32 %12, -1000
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 5000
%16 = add nsw i32 %15, -1000
%17 = tail call i32 (...) @rand()
%18 = srem i32 %17, 5000
%19 = add nsw i32 %18, -1000
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, 5000
%22 = add nsw i32 %21, -1000
%23 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %13, i32 %16, i32 %19, i32 %22)
%24 = tail call i32 @f(i32 %10, i32 %13, i32 %16, i32 %19, i32 %22)
%25 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = tail call i32 @g(i32 %10, i32 %13, i32 %16, i32 %19, i32 %22)
%27 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = icmp eq i32 %24, %26
br i1 %28, label %3, label %29
29: ; preds = %3, %6
%30 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_SUCCESS, %3 ]
%31 = load i32, i32* %30
ret i32 %31
}