#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 */
int /*<<< orphan*/ assert(int);
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int random();
int /*<<< orphan*/ srandom(int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 4) {
    fprintf(stderr, "usage: strgen <file> <count> <seed>\n");
    exit(1);
  }
  char *infile = argv[1];
  int count = atoi(argv[2]);
  int seed = atoi(argv[3]);
  assert(count > 0);
  (void)srandom(seed);
  FILE *fp = fopen(infile, "w");
  assert(fp != NULL);
  int i;
  for (i = 0; i < count; i++) {
    int value = (random() % 50000) - 25000;
    if (value < 0) {
      fprintf(fp, "- %d\n", -value);
    } else {
      fprintf(fp, "%d\n", value);
    }
  }
  fclose(fp);
  return 0;
}


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)
cmpl   $0x4,-0x8(%rbp)
je     11c2 <main+0x42>
mov    0x2e39(%rip),%rax
movslq (%rax),%rdi
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x20(%rbp),%edi
call   1030 <srandom@plt>
mov    -0x18(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12a6 <main+0x126>
mov    $0x0,%al
call   1070 <random@plt>
mov    $0xc350,%ecx
cltd
idiv   %ecx
sub    $0x61a8,%edx
mov    %edx,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jge    127e <main+0xfe>
mov    -0x28(%rbp),%rdi
xor    %edx,%edx
sub    -0x30(%rbp),%edx
lea    0xdb5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1293 <main+0x113>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%edx
lea    0xd9d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1298 <main+0x118>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1234 <main+0xb4>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x4,%edi
jne    127a <main+0xea>
mov    %rsi,%r14
mov    0x8(%rsi),%r15
mov    0x10(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebx
mov    0x18(%r14),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
xor    %edi,%edi
test   %ebx,%ebx
setg   %dil
call   1050 <assert@plt>
mov    %ebp,%edi
call   1030 <srandom@plt>
lea    0xe4c(%rip),%rsi
mov    %r15,%rdi
call   1080 <fopen@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
test   %ebx,%ebx
jle    1267 <main+0xd7>
lea    0xe2a(%rip),%r15
lea    0xe25(%rip),%r12
jmp    1228 <main+0x98>
cs nopw 0x0(%rax,%rax,1)
add    $0xffff9e58,%edx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0xffffffff,%ebx
je     1267 <main+0xd7>
xor    %eax,%eax
call   1070 <random@plt>
movslq %eax,%rdx
imul   $0x14f8b589,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0xc350,%eax,%eax
sub    %eax,%edx
cmp    $0x61a7,%edx
jg     1210 <main+0x80>
mov    $0x61a8,%eax
sub    %edx,%eax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
jmp    121c <main+0x8c>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d5f(%rip),%rax
movslq (%rax),%rcx
lea    0xd75(%rip),%rdi
mov    $0x24,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [37 x i8] c"usage: strgen <file> <count> <seed>\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [6 x i8] c"- %d\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 4
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i32*
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
store i8* %23, i8** %6
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %7
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %8
%32 = load i32, i32* %7
%33 = icmp sgt i32 %32, 0
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load i32, i32* %8
%37 = call i32 @srandom(i32 %36)
%38 = load i8*, i8** %6
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %39, i32** %9
%40 = load i32*, i32** %9
%41 = icmp ne i32* %40, null
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
store i32 0, i32* %10
br label %44
44: ; preds = %64, %20
%45 = load i32, i32* %10
%46 = load i32, i32* %7
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %67
48: ; preds = %44
%49 = call i32 (...) @random()
%50 = srem i32 %49, 50000
%51 = sub nsw i32 %50, 25000
store i32 %51, i32* %11
%52 = load i32, i32* %11
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %48
%55 = load i32*, i32** %9
%56 = load i32, i32* %11
%57 = sub nsw i32 0, %56
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %57)
br label %63
59: ; preds = %48
%60 = load i32*, i32** %9
%61 = load i32, i32* %11
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %59, %54
br label %64
64: ; preds = %63
%65 = load i32, i32* %10
%66 = add nsw i32 %65, 1
store i32 %66, i32* %10
br label %44
67: ; preds = %44
%68 = load i32*, i32** %9
%69 = call i32 @fclose(i32* %68)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [37 x i8] c"usage: strgen <file> <count> <seed>\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [6 x i8] c"- %d\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i64 36, i64 1, i32* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = icmp sgt i32 %15, 0
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i32 @srandom(i32 %18)
%23 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp ne i32* %23, null
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
br i1 %19, label %27, label %41
27: ; preds = %10, %38
%28 = phi i32 [ %39, %38 ], [ 0, %10 ]
%29 = tail call i32 (...) @random()
%30 = srem i32 %29, 50000
%31 = icmp slt i32 %30, 25000
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = sub nsw i32 25000, %30
%34 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %33)
br label %38
35: ; preds = %27
%36 = add nsw i32 %30, -25000
%37 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %32
%39 = add nuw nsw i32 %28, 1
%40 = icmp eq i32 %39, %15
br i1 %40, label %41, label %27
41: ; preds = %38, %10
%42 = tail call i32 @fclose(i32* %23)
ret i32 0
}