#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 *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/, char *, int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main() {
  int i, n;
  FILE *fich;
  fprintf(stdout, "Dime de que numero quieres la tabla: ");
  fscanf(stdin, "%d", &n);
  fich = fopen("tabla.txt", "a");
  for (i = 0; i <= 10; i = i + 1) {
    fprintf(fich, "%2d x %2d = %3d\n", i, n, i * n);
  }
  fclose(fich);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
movslq (%rax),%rdi
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xeaf(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <fscanf@plt>
lea    0xea2(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jg     11d7 <main+0x97>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%r8d
imul   -0xc(%rbp),%r8d
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119e <main+0x5e>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e7d(%rip),%rax
movslq (%rax),%rcx
lea    0xe9b(%rip),%rdi
mov    $0x25,%esi
mov    $0x1,%edx
call   1070 <fwrite@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xea2(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1040 <fscanf@plt>
lea    0xe94(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    0x4(%rsp),%ecx
lea    0xe86(%rip),%r14
mov    %rax,%rdi
mov    %r14,%rsi
xor    %edx,%edx
xor    %r8d,%r8d
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x4(%rsp),%ecx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
mov    %ecx,%r8d
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x4(%rsp),%ecx
lea    (%rcx,%rcx,1),%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x4(%rsp),%ecx
lea    (%rcx,%rcx,2),%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x4(%rsp),%ecx
lea    0x0(,%rcx,4),%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x4(%rsp),%ecx
lea    (%rcx,%rcx,4),%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x4(%rsp),%ecx
lea    (%rcx,%rcx,1),%eax
lea    (%rax,%rax,2),%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x4(%rsp),%ecx
lea    0x0(,%rcx,8),%r8d
sub    %ecx,%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x4(%rsp),%ecx
lea    0x0(,%rcx,8),%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x4(%rsp),%ecx
lea    (%rcx,%rcx,8),%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x4(%rsp),%ecx
lea    (%rcx,%rcx,1),%eax
lea    (%rax,%rax,4),%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [38 x i8] c"Dime de que numero quieres la tabla: \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"tabla.txt\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [17 x i8] c"%2d x %2d = %3d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
%5 = load i32, i32* @stdout
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @stdin
%10 = call i32 @fscanf(i32 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %11, i32** %4
store i32 0, i32* %2
br label %12
12: ; preds = %23, %0
%13 = load i32, i32* %2
%14 = icmp sle i32 %13, 10
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = load i32*, i32** %4
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = mul nsw i32 %19, %20
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %17, i32 %18, i32 %21)
br label %23
23: ; preds = %15
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %12
26: ; preds = %12
%27 = load i32*, i32** %4
%28 = call i32 @fclose(i32* %27)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [38 x i8] c"Dime de que numero quieres la tabla: \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"tabla.txt\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [17 x i8] c"%2d x %2d = %3d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @stdout
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to i32*
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i64 37, i64 1, i32* %5)
%7 = load i32, i32* @stdin
%8 = call i32 @fscanf(i32 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 %10, i32 0)
%12 = load i32, i32* %1
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 %12, i32 %12)
%14 = load i32, i32* %1
%15 = shl nsw i32 %14, 1
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 2, i32 %14, i32 %15)
%17 = load i32, i32* %1
%18 = mul nsw i32 %17, 3
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 3, i32 %17, i32 %18)
%20 = load i32, i32* %1
%21 = shl nsw i32 %20, 2
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 4, i32 %20, i32 %21)
%23 = load i32, i32* %1
%24 = mul nsw i32 %23, 5
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 5, i32 %23, i32 %24)
%26 = load i32, i32* %1
%27 = mul nsw i32 %26, 6
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 6, i32 %26, i32 %27)
%29 = load i32, i32* %1
%30 = mul nsw i32 %29, 7
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 7, i32 %29, i32 %30)
%32 = load i32, i32* %1
%33 = shl nsw i32 %32, 3
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 8, i32 %32, i32 %33)
%35 = load i32, i32* %1
%36 = mul nsw i32 %35, 9
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 9, i32 %35, i32 %36)
%38 = load i32, i32* %1
%39 = mul nsw i32 %38, 10
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 10, i32 %38, i32 %39)
%41 = call i32 @fclose(i32* %9)
ret i32 0
}