#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*/ printf(char *, int, int);
int /*<<< orphan*/ puts(char *);
int rand();
int /*<<< orphan*/ srand(int);
int main(void) {
  int i1, i2;
  int j1, j2;
  i1 = rand();
  i2 = rand();
  srand(1);
  j1 = rand();
  j2 = rand();
  if (i1 < 0 || i2 < 0 || j1 < 0 || j2 < 0) {
    puts("Test FAILED!");
  }
  if (j1 == i1 && j2 == i2) {
    puts("Test succeeded.");
    return 0;
  } else {
    if (j1 != i1)
      printf("%d != %d\n", j1, i1);
    if (j2 != i2)
      printf("%d != %d\n", j2, i2);
    puts("Test FAILED!");
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,-0xc(%rbp)
mov    $0x1,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11a9 <main+0x69>
cmpl   $0x0,-0xc(%rbp)
jl     11a9 <main+0x69>
cmpl   $0x0,-0x10(%rbp)
jl     11a9 <main+0x69>
cmpl   $0x0,-0x14(%rbp)
jge    11b5 <main+0x75>
lea    0xe50(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11e5 <main+0xa5>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11e5 <main+0xa5>
lea    0xe39(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1234 <main+0xf4>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     1203 <main+0xc3>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1221 <main+0xe1>
mov    -0x14(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe01(%rip),%rdi
call   1040 <printf@plt>
lea    0xdd8(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%r14d
mov    $0x1,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%r15d
test   %ebp,%ebp
js     1189 <main+0x49>
test   %r14d,%r14d
js     1189 <main+0x49>
test   %ebx,%ebx
js     1189 <main+0x49>
test   %r15d,%r15d
jns    1195 <main+0x55>
lea    0xe70(%rip),%rdi
call   1030 <puts@plt>
cmp    %ebp,%ebx
jne    11a9 <main+0x69>
cmp    %r14d,%r15d
jne    11a9 <main+0x69>
xor    %ebx,%ebx
lea    0xe66(%rip),%rbp
jmp    11e0 <main+0xa0>
cmp    %ebp,%ebx
je     11bd <main+0x7d>
lea    0xe69(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1040 <printf@plt>
mov    $0x1,%ebx
lea    0xe37(%rip),%rbp
cmp    %r14d,%r15d
je     11e0 <main+0xa0>
lea    0xe48(%rip),%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Test FAILED!\00"
@.str.1 = [16 x i8] c"Test succeeded.\00"
@.str.2 = [10 x i8] c"%d != %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @rand()
store i32 %6, i32* %2
%7 = call i32 (...) @rand()
store i32 %7, i32* %3
%8 = call i32 @srand(i32 1)
%9 = call i32 (...) @rand()
store i32 %9, i32* %4
%10 = call i32 (...) @rand()
store i32 %10, i32* %5
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %0
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19, %16, %13, %0
%23 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
%25 = load i32, i32* %4
%26 = load i32, i32* %2
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = load i32, i32* %5
%30 = load i32, i32* %3
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %52
34: ; preds = %28, %24
%35 = load i32, i32* %4
%36 = load i32, i32* %2
%37 = icmp ne i32 %35, %36
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i32, i32* %4
%40 = load i32, i32* %2
%41 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %40)
br label %42
42: ; preds = %38, %34
%43 = load i32, i32* %5
%44 = load i32, i32* %3
%45 = icmp ne i32 %43, %44
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load i32, i32* %5
%48 = load i32, i32* %3
%49 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %47, i32 %48)
br label %50
50: ; preds = %46, %42
%51 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %52
52: ; preds = %50, %32
%53 = load i32, i32* %1
ret i32 %53
}

LLVM IR (-O2):
@.str = [13 x i8] c"Test FAILED!\00"
@.str.1 = [16 x i8] c"Test succeeded.\00"
@.str.2 = [10 x i8] c"%d != %d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @rand()
%2 = tail call i32 (...) @rand()
%3 = tail call i32 @srand(i32 1)
%4 = tail call i32 (...) @rand()
%5 = tail call i32 (...) @rand()
%6 = icmp slt i32 %1, 0
%7 = icmp slt i32 %2, 0
%8 = select i1 %6, i1 true, i1 %7
%9 = icmp slt i32 %4, 0
%10 = select i1 %8, i1 true, i1 %9
%11 = icmp slt i32 %5, 0
%12 = select i1 %10, i1 true, i1 %11
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %0, %13
%16 = icmp eq i32 %4, %1
%17 = icmp eq i32 %5, %2
%18 = select i1 %16, i1 %17, i1 false
br i1 %18, label %25, label %19
19: ; preds = %15
br i1 %16, label %22, label %20
20: ; preds = %19
%21 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %1)
br label %22
22: ; preds = %20, %19
br i1 %17, label %25, label %23
23: ; preds = %22
%24 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %5, i32 %2)
br label %25
25: ; preds = %22, %23, %15
%26 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), %15 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %23 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %22 ]
%27 = phi i32 [ 0, %15 ], [ 1, %23 ], [ 1, %22 ]
%28 = tail call i32 @puts(i8* dereferenceable(1) %26)
ret i32 %27
}