#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, int, char, int);
int main(int argc, char **argv) {
  FILE *archivo_out;
  char linea_out[71];
  archivo_out = fopen("data_in.txt", "w");
  if (archivo_out == NULL)
    exit(1);
  int nro;
  if (argc > 0)
    nro = atoi(argv[1]);
  else
    nro = 1000;
  int i = 0;
  int p1;
  int p2;
  char op;
  int valop;
  while (i < nro) {
    p1 = rand() % 100 + 1;
    p2 = rand() % 100 + 1;
    valop = rand() % 256;
    if (valop > 192)
      op = '/';
    else if (valop > 128)
      op = '*';
    else if (valop > 64)
      op = '-';
    else
      op = '/';
    sprintf(linea_out, "%d %c %d = \n", p1, op, p2);
    fputs(linea_out, archivo_out);
    i++;
  }
  fclose(archivo_out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe70(%rip),%rdi
lea    0xe75(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b5 <main+0x45>
mov    $0x1,%edi
call   1080 <exit@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11d4 <main+0x64>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x64(%rbp)
jmp    11db <main+0x6b>
movl   $0x3e8,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    12af <main+0x13f>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x6c(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x70(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x78(%rbp)
cmpl   $0xc0,-0x78(%rbp)
jle    1240 <main+0xd0>
movb   $0x2f,-0x71(%rbp)
jmp    1277 <main+0x107>
cmpl   $0x80,-0x78(%rbp)
jle    1256 <main+0xe6>
movb   $0x2a,-0x71(%rbp)
jmp    1272 <main+0x102>
cmpl   $0x40,-0x78(%rbp)
jle    1269 <main+0xf9>
movb   $0x2d,-0x71(%rbp)
jmp    126d <main+0xfd>
movb   $0x2f,-0x71(%rbp)
jmp    1272 <main+0x102>
jmp    1277 <main+0x107>
lea    -0x60(%rbp),%rdi
mov    -0x6c(%rbp),%edx
mov    -0x71(%rbp),%al
mov    -0x70(%rbp),%r8d
lea    0xd82(%rip),%rsi
movsbl %al,%ecx
call   1070 <sprintf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11e2 <main+0x72>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe76(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     12a1 <main+0x131>
test   %ebp,%ebp
jle    11d2 <main+0x62>
mov    0x8(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
test   %eax,%eax
jg     11d7 <main+0x67>
mov    0x8(%rsp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x3e8,%ebp
lea    0x10(%rsp),%r12
jmp    1210 <main+0xa0>
xchg   %ax,%ax
lea    (%r14,%r13,1),%edx
add    $0x1,%edx
lea    0x1(%rbx,%r15,1),%r8d
movzbl %cl,%ecx
mov    %r12,%rdi
lea    0xe15(%rip),%rsi
call   1070 <sprintf@plt>
mov    %r12,%rdi
mov    0x8(%rsp),%rsi
call   1040 <fputs@plt>
add    $0xffffffff,%ebp
je     11b7 <main+0x47>
xor    %eax,%eax
call   1090 <rand@plt>
mov    %eax,%r13d
cltq
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%r14d
neg    %r14d
xor    %eax,%eax
call   1090 <rand@plt>
mov    %eax,%ebx
cltq
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%r15d
neg    %r15d
xor    %eax,%eax
call   1090 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
mov    $0x2f,%cl
cmp    $0xc0,%eax
jg     11e0 <main+0x70>
mov    $0x2a,%cl
cmp    $0x80,%eax
jg     11e0 <main+0x70>
cmp    $0x41,%eax
setl   %cl
add    %cl,%cl
or     $0x2d,%cl
jmp    11e0 <main+0x70>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"data_in.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [13 x i8] c"%d %c %d = \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [71 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %6
%15 = load i32*, i32** %6
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %8
br label %28
27: ; preds = %19
store i32 1000, i32* %8
br label %28
28: ; preds = %27, %22
store i32 0, i32* %9
br label %29
29: ; preds = %56, %28
%30 = load i32, i32* %9
%31 = load i32, i32* %8
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %67
33: ; preds = %29
%34 = call i32 (...) @rand()
%35 = srem i32 %34, 100
%36 = add nsw i32 %35, 1
store i32 %36, i32* %10
%37 = call i32 (...) @rand()
%38 = srem i32 %37, 100
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
%40 = call i32 (...) @rand()
%41 = srem i32 %40, 256
store i32 %41, i32* %13
%42 = load i32, i32* %13
%43 = icmp sgt i32 %42, 192
br i1 %43, label %44, label %45
44: ; preds = %33
store i8 47, i8* %12
br label %56
45: ; preds = %33
%46 = load i32, i32* %13
%47 = icmp sgt i32 %46, 128
br i1 %47, label %48, label %49
48: ; preds = %45
store i8 42, i8* %12
br label %55
49: ; preds = %45
%50 = load i32, i32* %13
%51 = icmp sgt i32 %50, 64
br i1 %51, label %52, label %53
52: ; preds = %49
store i8 45, i8* %12
br label %54
53: ; preds = %49
store i8 47, i8* %12
br label %54
54: ; preds = %53, %52
br label %55
55: ; preds = %54, %48
br label %56
56: ; preds = %55, %44
%57 = getelementptr inbounds [71 x i8], [71 x i8]* %7, i64 0, i64 0
%58 = load i32, i32* %10
%59 = load i8, i8* %12
%60 = load i32, i32* %11
%61 = call i32 @sprintf(i8* %57, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %58, i8 signext %59, i32 %60)
%62 = getelementptr inbounds [71 x i8], [71 x i8]* %7, i64 0, i64 0
%63 = load i32*, i32** %6
%64 = call i32 @fputs(i8* %62, i32* %63)
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 1
store i32 %66, i32* %9
br label %29
67: ; preds = %29
%68 = load i32*, i32** %6
%69 = call i32 @fclose(i32* %68)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"data_in.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [13 x i8] c"%d %c %d = \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [71 x i8]
%4 = getelementptr inbounds [71 x i8], [71 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %16
11: ; preds = %9
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %40
16: ; preds = %9, %11
%17 = phi i32 [ %14, %11 ], [ 1000, %9 ]
br label %18
18: ; preds = %16, %34
%19 = phi i32 [ %38, %34 ], [ 0, %16 ]
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, 100
%22 = add nsw i32 %21, 1
%23 = tail call i32 (...) @rand()
%24 = srem i32 %23, 100
%25 = add nsw i32 %24, 1
%26 = tail call i32 (...) @rand()
%27 = srem i32 %26, 256
%28 = icmp sgt i32 %27, 192
br i1 %28, label %34, label %29
29: ; preds = %18
%30 = icmp sgt i32 %27, 128
br i1 %30, label %34, label %31
31: ; preds = %29
%32 = icmp sgt i32 %27, 64
%33 = select i1 %32, i8 45, i8 47
br label %34
34: ; preds = %31, %29, %18
%35 = phi i8 [ 47, %18 ], [ 42, %29 ], [ %33, %31 ]
%36 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %22, i8 signext %35, i32 %25)
%37 = call i32 @fputs(i8* %4, i32* %5)
%38 = add nuw nsw i32 %19, 1
%39 = icmp eq i32 %38, %17
br i1 %39, label %40, label %18
40: ; preds = %34, %11
%41 = tail call i32 @fclose(i32* %5)
ret i32 0
}