#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
long atol(char *);
int ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int rand();
int /*<<< orphan*/ s4(int /*<<< orphan*/ *, long);
int /*<<< orphan*/ sn(int /*<<< orphan*/ *, long);
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  FILE *out = stdout;
  long count = 0;
  int four = 0;
  if (argc > 1 && !strcmp(argv[1], "-4")) {
    four = 4;
    argc--;
    argv++;
  }
  if (argc > 1)
    count = atol(argv[1]);
  if (count == 0)
    count = rand() % 100000;
  if (four)
    s4(out, count);
  else
    sn(out, count);
  fflush(out);
  return ferror(out);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e53(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11e6 <main+0x76>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe44(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11e6 <main+0x76>
movl   $0x4,-0x24(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1201 <main+0x91>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atol@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1222 <main+0xb2>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x186a0,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     123e <main+0xce>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <s4@plt>
jmp    124b <main+0xdb>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <sn@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fflush@plt>
mov    -0x18(%rbp),%rdi
call   1030 <ferror@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e62(%rip),%rax
mov    (%rax),%r14
cmp    $0x2,%edi
jl     11b2 <main+0x42>
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x8(%rsi),%rbx
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11fc <main+0x8c>
mov    %rbx,%rdi
call   1080 <atol@plt>
mov    %rax,%rsi
test   %rax,%rax
jne    11da <main+0x6a>
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x14f8b589,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2d,%rcx
add    %edx,%ecx
imul   $0x186a0,%ecx,%ecx
sub    %ecx,%eax
movslq %eax,%rsi
mov    %r14,%rdi
call   1050 <sn@plt>
mov    %r14,%rdi
call   1070 <fflush@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <ferror@plt>
add    $0xfffffffd,%ebp
cmp    $0xfffffffd,%ebp
ja     1215 <main+0xa5>
mov    0x10(%r15),%rdi
call   1080 <atol@plt>
mov    %rax,%rsi
test   %rax,%rax
jne    123d <main+0xcd>
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x14f8b589,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2d,%rcx
add    %edx,%ecx
imul   $0x186a0,%ecx,%ecx
sub    %ecx,%eax
movslq %eax,%rsi
mov    %r14,%rdi
call   1040 <s4@plt>
jmp    11e2 <main+0x72>

LLVM IR (-O0):
@stdout = global i32* null
@.str = [3 x i8] c"-4\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32*, i32** @stdout
store i32* %9, i32** %6
store i64 0, i64* %7
store i32 0, i32* %8
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %23
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %12
store i32 4, i32* %8
%19 = load i32, i32* %4
%20 = add nsw i32 %19, -1
store i32 %20, i32* %4
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i32 1
store i8** %22, i8*** %5
br label %23
23: ; preds = %18, %12, %2
%24 = load i32, i32* %4
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i64 @atol(i8* %29)
store i64 %30, i64* %7
br label %31
31: ; preds = %26, %23
%32 = load i64, i64* %7
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = call i32 (...) @rand()
%36 = srem i32 %35, 100000
%37 = sext i32 %36 to i64
store i64 %37, i64* %7
br label %38
38: ; preds = %34, %31
%39 = load i32, i32* %8
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i32*, i32** %6
%43 = load i64, i64* %7
%44 = call i32 @s4(i32* %42, i64 %43)
br label %49
45: ; preds = %38
%46 = load i32*, i32** %6
%47 = load i64, i64* %7
%48 = call i32 @sn(i32* %46, i64 %47)
br label %49
49: ; preds = %45, %41
%50 = load i32*, i32** %6
%51 = call i32 @fflush(i32* %50)
%52 = load i32*, i32** %6
%53 = call i32 @ferror(i32* %52)
ret i32 %53
}

LLVM IR (-O2):
@stdout = global i32* null
@.str = [3 x i8] c"-4\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32*, i32** @stdout
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %28
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %7, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %5
%11 = add nsw i32 %0, -3
%12 = icmp ult i32 %11, -2
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i64 @atol(i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %25
18: ; preds = %5
%19 = tail call i64 @atol(i8* %7)
%20 = icmp eq i64 %19, 0
br i1 %20, label %28, label %32
21: ; preds = %13, %10
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 100000
%24 = sext i32 %23 to i64
br label %25
25: ; preds = %21, %13
%26 = phi i64 [ %16, %13 ], [ %24, %21 ]
%27 = tail call i32 @s4(i32* %3, i64 %26)
br label %35
28: ; preds = %18, %2
%29 = tail call i32 (...) @rand()
%30 = srem i32 %29, 100000
%31 = sext i32 %30 to i64
br label %32
32: ; preds = %28, %18
%33 = phi i64 [ %19, %18 ], [ %31, %28 ]
%34 = tail call i32 @sn(i32* %3, i64 %33)
br label %35
35: ; preds = %32, %25
%36 = tail call i32 @fflush(i32* %3)
%37 = tail call i32 @ferror(i32* %3)
ret i32 %37
}