#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ free(char *);
char *make_word(int);
int /*<<< orphan*/ printf(char *);
int rand();
int main(int argc, char *argv[]) {
  FILE *f;
  int i;
  char *word;
  char *mean;
  if (argc < 2)
    printf("Ban nhap sai doi so\n");
  f = fopen(argv[1], "w");
  for (i = 0; i < 10000; i++) {
    word = make_word(rand() % 10 + 4);
    mean = make_word(7);
    fprintf(f, "%s\t%s\n", word, mean);
    free(word);
  }
  fclose(f);
  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   $0x2,-0x8(%rbp)
jge    119c <main+0x2c>
lea    0xe69(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2710,-0x1c(%rbp)
jge    1222 <main+0xb2>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x4,%edi
call   1040 <make_word@plt>
mov    %rax,-0x28(%rbp)
mov    $0x7,%edi
call   1040 <make_word@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xe11(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bb <main+0x4b>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     118b <main+0x1b>
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rbx),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
mov    $0x2710,%ebp
lea    0xe58(%rip),%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0x4,%edi
call   1050 <make_word@plt>
mov    %rax,%rbx
mov    $0x7,%edi
call   1050 <make_word@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x40>
mov    %r15,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Ban nhap sai doi so\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%s\09%s\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 i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
store i32 0, i32* %7
br label %19
19: ; preds = %34, %14
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 10000
br i1 %21, label %22, label %37
22: ; preds = %19
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 10
%25 = add nsw i32 %24, 4
%26 = call i8* @make_word(i32 %25)
store i8* %26, i8** %8
%27 = call i8* @make_word(i32 7)
store i8* %27, i8** %9
%28 = load i32*, i32** %6
%29 = load i8*, i8** %8
%30 = load i8*, i8** %9
%31 = call i32 @fprintf(i32* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* %30)
%32 = load i8*, i8** %8
%33 = call i32 @free(i8* %32)
br label %34
34: ; preds = %22
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %19
37: ; preds = %19
%38 = load i32*, i32** %6
%39 = call i32 @fclose(i32* %38)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%s\09%s\0A\00"
@str = [20 x i8] c"Ban nhap sai doi so\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 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* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %6, %10
%11 = phi i32 [ 0, %6 ], [ %19, %10 ]
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 10
%14 = add nsw i32 %13, 4
%15 = tail call i8* @make_word(i32 %14)
%16 = tail call i8* @make_word(i32 7)
%17 = tail call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %15, i8* %16)
%18 = tail call i32 @free(i8* %15)
%19 = add nuw nsw i32 %11, 1
%20 = icmp eq i32 %19, 10000
br i1 %20, label %21, label %10
21: ; preds = %10
%22 = tail call i32 @fclose(i32* %9)
ret i32 0
}