#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 atoi(char *);
int /*<<< orphan*/ closegfsr(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ intrand();
int /*<<< orphan*/ isdigit(char);
scalar_t__ malloc(int);
int /*<<< orphan*/ opengfsr(char *);
int /*<<< orphan*/ printerr(char *);
int /*<<< orphan*/ printf(char *);
char *realloc(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  int iter, i, cut, niter, homesize;
  char *home;
  if (argc != 2)
    printerr("needs niter");
  for (iter = 0; iter < strlen(argv[1]); iter++)
    if (!(isdigit(argv[1][iter])))
      printerr("argument is not a number");
  homesize = strlen(argv[0]) + 5;
  home = (char *)malloc(homesize * sizeof(char));
  strcpy(home, argv[0]);
  for (cut = -1, i = homesize - 1; home[i] != '/' && home[i] != '\\' && i >= 0;
       cut++, i--) {
    home[i] = '\0';
  }
  home = realloc(home, (homesize - cut) * sizeof(char));
  niter = atoi(argv[1]);
  printf("\n\n  start of randomization of INTFILE...\n");
  opengfsr(home);
  for (iter = 0; iter < niter; iter++) {
    intrand();
  }
  closegfsr(home);
  printf("\n  ...INTFILE randomized\n\n");
  free(home);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ec <main+0x2c>
lea    0xe19(%rip),%rdi
call   10a0 <printerr@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    1250 <main+0x90>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%eax
jne    123d <main+0x7d>
lea    0xdd4(%rip),%rdi
call   10a0 <printerr@plt>
jmp    1242 <main+0x82>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f3 <main+0x33>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <strlen@plt>
add    $0x5,%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1060 <strcpy@plt>
movl   $0xffffffff,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0x35(%rbp)
je     12d3 <main+0x113>
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x5c,%ecx
mov    %al,-0x35(%rbp)
je     12d3 <main+0x113>
cmpl   $0x0,-0x18(%rbp)
setge  %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    12e3 <main+0x123>
jmp    1306 <main+0x146>
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1295 <main+0xd5>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%eax
sub    -0x1c(%rbp),%eax
cltq
shl    $0x0,%rax
mov    %eax,%esi
call   10d0 <realloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x20(%rbp)
lea    0xced(%rip),%rdi
call   1090 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1070 <opengfsr@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    136e <main+0x1ae>
mov    $0x0,%al
call   1050 <intrand@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    134d <main+0x18d>
mov    -0x30(%rbp),%rdi
call   10c0 <closegfsr@plt>
lea    0xcd1(%rip),%rdi
call   1090 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
je     11db <main+0x1b>
lea    0xe2a(%rip),%rdi
call   10a0 <printerr@plt>
mov    0x8(%rbx),%rdi
call   1090 <strlen@plt>
test   %eax,%eax
jle    122f <main+0x6f>
xor    %ebp,%ebp
lea    0xe1b(%rip),%r14
jmp    1214 <main+0x54>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
mov    0x8(%rbx),%rdi
call   1090 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    122f <main+0x6f>
mov    0x8(%rbx),%rax
movsbl (%rax,%rbp,1),%edi
call   1040 <isdigit@plt>
test   %eax,%eax
jne    1200 <main+0x40>
mov    %r14,%rdi
call   10a0 <printerr@plt>
jmp    1200 <main+0x40>
mov    (%rbx),%rdi
call   1090 <strlen@plt>
mov    %eax,%r15d
lea    0x5(%r15),%r14d
mov    %r14d,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbp
mov    (%rbx),%rsi
mov    %rax,%rdi
call   1060 <strcpy@plt>
movslq %r15d,%rcx
mov    0x4(%rbp,%rcx,1),%dl
mov    $0xffffffff,%eax
cmp    $0x2f,%dl
je     1290 <main+0xd0>
add    $0x4,%rcx
mov    $0xffffffff,%eax
xchg   %ax,%ax
cmp    $0x5c,%dl
je     1290 <main+0xd0>
test   %rcx,%rcx
js     1290 <main+0xd0>
movb   $0x0,0x0(%rbp,%rcx,1)
add    $0x1,%eax
movzbl -0x1(%rbp,%rcx,1),%edx
add    $0xffffffffffffffff,%rcx
cmp    $0x2f,%dl
jne    1270 <main+0xb0>
sub    %eax,%r14d
mov    %rbp,%rdi
mov    %r14d,%esi
call   10d0 <realloc@plt>
mov    %rax,%rbp
mov    0x8(%rbx),%rdi
call   10e0 <atoi@plt>
mov    %eax,%ebx
lea    0xd72(%rip),%rdi
call   1070 <puts@plt>
mov    %rbp,%rdi
call   1080 <opengfsr@plt>
test   %ebx,%ebx
jle    12dc <main+0x11c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <intrand@plt>
add    $0xffffffff,%ebx
jne    12d0 <main+0x110>
mov    %rbp,%rdi
call   10c0 <closegfsr@plt>
lea    0xd63(%rip),%rdi
call   1070 <puts@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"needs niter\00"
@.str.1 = [25 x i8] c"argument is not a number\00"
@.str.2 = [42 x i8] c"\0A\0A start of randomization of INTFILE...\0A\00"
@.str.3 = [27 x i8] c"\0A ...INTFILE randomized\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
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, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @printerr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %2
store i32 0, i32* %6
br label %17
17: ; preds = %37, %16
%18 = load i32, i32* %6
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strlen(i8* %21)
%23 = icmp slt i32 %18, %22
br i1 %23, label %24, label %40
24: ; preds = %17
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = call i32 @isdigit(i8 signext %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %24
%35 = call i32 @printerr(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %34, %24
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %17
40: ; preds = %17
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i32 @strlen(i8* %43)
%45 = add nsw i32 %44, 5
store i32 %45, i32* %10
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = mul i64 %47, 1
%49 = trunc i64 %48 to i32
%50 = call i64 @malloc(i32 %49)
%51 = inttoptr i64 %50 to i8*
store i8* %51, i8** %11
%52 = load i8*, i8** %11
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 0
%55 = load i8*, i8** %54
%56 = call i32 @strcpy(i8* %52, i8* %55)
store i32 -1, i32* %8
%57 = load i32, i32* %10
%58 = sub nsw i32 %57, 1
store i32 %58, i32* %7
br label %59
59: ; preds = %85, %40
%60 = load i8*, i8** %11
%61 = load i32, i32* %7
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 47
br i1 %66, label %67, label %78
67: ; preds = %59
%68 = load i8*, i8** %11
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp ne i32 %73, 92
br i1 %74, label %75, label %78
75: ; preds = %67
%76 = load i32, i32* %7
%77 = icmp sge i32 %76, 0
br label %78
78: ; preds = %75, %67, %59
%79 = phi i1 [ false, %67 ], [ false, %59 ], [ %77, %75 ]
br i1 %79, label %80, label %90
80: ; preds = %78
%81 = load i8*, i8** %11
%82 = load i32, i32* %7
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
store i8 0, i8* %84
br label %85
85: ; preds = %80
%86 = load i32, i32* %8
%87 = add nsw i32 %86, 1
store i32 %87, i32* %8
%88 = load i32, i32* %7
%89 = add nsw i32 %88, -1
store i32 %89, i32* %7
br label %59
90: ; preds = %78
%91 = load i8*, i8** %11
%92 = load i32, i32* %10
%93 = load i32, i32* %8
%94 = sub nsw i32 %92, %93
%95 = sext i32 %94 to i64
%96 = mul i64 %95, 1
%97 = trunc i64 %96 to i32
%98 = call i8* @realloc(i8* %91, i32 %97)
store i8* %98, i8** %11
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 1
%101 = load i8*, i8** %100
%102 = call i32 @atoi(i8* %101)
store i32 %102, i32* %9
%103 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%104 = load i8*, i8** %11
%105 = call i32 @opengfsr(i8* %104)
store i32 0, i32* %6
br label %106
106: ; preds = %112, %90
%107 = load i32, i32* %6
%108 = load i32, i32* %9
%109 = icmp slt i32 %107, %108
br i1 %109, label %110, label %115
110: ; preds = %106
%111 = call i32 (...) @intrand()
br label %112
112: ; preds = %110
%113 = load i32, i32* %6
%114 = add nsw i32 %113, 1
store i32 %114, i32* %6
br label %106
115: ; preds = %106
%116 = load i8*, i8** %11
%117 = call i32 @closegfsr(i8* %116)
%118 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%119 = load i8*, i8** %11
%120 = call i32 @free(i8* %119)
%121 = load i32, i32* %3
ret i32 %121
}

LLVM IR (-O2):
@.str = [12 x i8] c"needs niter\00"
@.str.1 = [25 x i8] c"argument is not a number\00"
@str = [41 x i8] c"\0A\0A start of randomization of INTFILE...\00"
@str.4 = [26 x i8] c"\0A ...INTFILE randomized\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @printerr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* %8)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %26
11: ; preds = %6, %20
%12 = phi i64 [ %21, %20 ], [ 0, %6 ]
%13 = load i8*, i8** %7
%14 = getelementptr inbounds i8, i8* %13, i64 %12
%15 = load i8, i8* %14
%16 = tail call i32 @isdigit(i8 signext %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = tail call i32 @printerr(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %11, %18
%21 = add nuw nsw i64 %12, 1
%22 = load i8*, i8** %7
%23 = tail call i32 @strlen(i8* %22)
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %21, %24
br i1 %25, label %11, label %26
26: ; preds = %20, %6
%27 = load i8*, i8** %1
%28 = tail call i32 @strlen(i8* %27)
%29 = add nsw i32 %28, 5
%30 = tail call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to i8*
%32 = load i8*, i8** %1
%33 = tail call i32 @strcpy(i8* %31, i8* %32)
%34 = add nsw i32 %28, 4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %31, i64 %35
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 47
br i1 %38, label %53, label %39
39: ; preds = %26, %47
%40 = phi i64 [ %49, %47 ], [ %35, %26 ]
%41 = phi i8 [ %51, %47 ], [ %37, %26 ]
%42 = phi i8* [ %50, %47 ], [ %36, %26 ]
%43 = phi i32 [ %48, %47 ], [ -1, %26 ]
%44 = icmp ne i8 %41, 92
%45 = icmp sgt i64 %40, -1
%46 = select i1 %44, i1 %45, i1 false
br i1 %46, label %47, label %53
47: ; preds = %39
store i8 0, i8* %42
%48 = add nsw i32 %43, 1
%49 = add nsw i64 %40, -1
%50 = getelementptr inbounds i8, i8* %31, i64 %49
%51 = load i8, i8* %50
%52 = icmp eq i8 %51, 47
br i1 %52, label %53, label %39
53: ; preds = %39, %47, %26
%54 = phi i32 [ -1, %26 ], [ %48, %47 ], [ %43, %39 ]
%55 = sub nsw i32 %29, %54
%56 = tail call i8* @realloc(i8* %31, i32 %55)
%57 = load i8*, i8** %7
%58 = tail call i32 @atoi(i8* %57)
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%60 = tail call i32 @opengfsr(i8* %56)
%61 = icmp sgt i32 %58, 0
br i1 %61, label %62, label %67
62: ; preds = %53, %62
%63 = phi i32 [ %65, %62 ], [ 0, %53 ]
%64 = tail call i32 (...) @intrand()
%65 = add nuw nsw i32 %63, 1
%66 = icmp eq i32 %65, %58
br i1 %66, label %67, label %62
67: ; preds = %62, %53
%68 = tail call i32 @closegfsr(i8* %56)
%69 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.4, i64 0, i64 0))
%70 = tail call i32 @free(i8* %56)
ret i32 0
}