#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*/ PutSeed(long);
int Random();
int /*<<< orphan*/ SelectStream(int);
int atoi(char *);
int floor(int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  if (argc < 3) {
    printf("Not enough inputs:  seed target\n");
  }
  SelectStream(1);
  PutSeed((long)atoi(argv[1]));
  int done = 0;
  int c = 1000000000;
  while (!done) {
    c = floor(Random() * 1000000000);
    if (c == atoi(argv[2])) {
      printf("Found the bug!\n");
      done = 1;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    118c <main+0x2c>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1030 <SelectStream@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
movslq %eax,%rdi
call   1080 <PutSeed@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x3b9aca00,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11cf <main+0x6f>
jmp    121c <main+0xbc>
mov    $0x0,%al
call   1050 <Random@plt>
imul   $0x3b9aca00,%eax,%edi
call   1070 <floor@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jne    1217 <main+0xb7>
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    11b9 <main+0x59>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     1177 <main+0x17>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1040 <SelectStream@plt>
mov    0x8(%rbx),%rdi
call   1060 <atoi@plt>
movslq %eax,%rdi
call   1080 <PutSeed@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <Random@plt>
imul   $0x3b9aca00,%eax,%edi
call   1070 <floor@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
cmp    %eax,%ebp
jne    11a0 <main+0x40>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Not enough inputs: seed target\0A\00"
@.str.1 = [16 x i8] c"Found the bug!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = call i32 @SelectStream(i32 1)
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
%18 = sext i32 %17 to i64
%19 = call i32 @PutSeed(i64 %18)
store i32 0, i32* %6
store i32 1000000000, i32* %7
br label %20
20: ; preds = %36, %12
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br i1 %23, label %24, label %37
24: ; preds = %20
%25 = call i32 (...) @Random()
%26 = mul nsw i32 %25, 1000000000
%27 = call i32 @floor(i32 %26)
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
%33 = icmp eq i32 %28, %32
br i1 %33, label %34, label %36
34: ; preds = %24
%35 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %6
br label %36
36: ; preds = %34, %24
br label %20
37: ; preds = %20
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@str = [15 x i8] c"Found the bug!\00"
@str.2 = [32 x i8] c"Not enough inputs: seed target\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.2, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = tail call i32 @SelectStream(i32 1)
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = sext i32 %10 to i64
%12 = tail call i32 @PutSeed(i64 %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
br label %14
14: ; preds = %14, %6
%15 = tail call i32 (...) @Random()
%16 = mul nsw i32 %15, 1000000000
%17 = tail call i32 @floor(i32 %16)
%18 = load i8*, i8** %13
%19 = tail call i32 @atoi(i8* %18)
%20 = icmp eq i32 %17, %19
br i1 %20, label %21, label %14
21: ; preds = %14
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
ret i32 0
}