#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*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  FILE *ptr_file;
  int i;
  int num;
  char carac;
  char *ptr_ch;
  int *ptr_num;
  ptr_ch = &carac;
  ptr_num = &num;
  ptr_file = fopen("/root/practica2/Entrada2b.txt", "r");
  if (!ptr_file) {
    return 1;
  }
  while (1) {
    if (feof(ptr_file)) {
      break;
    }
    fscanf(ptr_file, "%s %d \n", ptr_ch, ptr_num);
    for (i = 0; i < *ptr_num; i++) {
      printf("%s", ptr_ch);
    }
    printf("\n");
  }
  fclose(ptr_file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x19(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119d <main+0x4d>
movl   $0x1,-0x4(%rbp)
jmp    122b <main+0xdb>
jmp    11a2 <main+0x52>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     11ba <main+0x6a>
jmp    121b <main+0xcb>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xe53(%rip),%rsi
call   1050 <fscanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x30(%rbp),%rcx
cmp    (%rcx),%eax
jge    1208 <main+0xb8>
mov    -0x28(%rbp),%rsi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d9 <main+0x89>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a2 <main+0x52>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     119f <main+0x3f>
mov    %rax,%r15
mov    %rax,%rdi
call   1070 <feof@plt>
test   %rax,%rax
je     11b3 <main+0x53>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11a4 <main+0x44>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe66(%rip),%r14
lea    0x3(%rsp),%rbx
lea    0x4(%rsp),%r12
lea    0xe5d(%rip),%r13
jmp    11e7 <main+0x87>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1070 <feof@plt>
test   %rax,%rax
jne    1193 <main+0x33>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1060 <fscanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11d0 <main+0x70>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     1210 <main+0xb0>
jmp    11d0 <main+0x70>

LLVM IR (-O0):
@.str = [30 x i8] c"/root/practica2/Entrada2b.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"%s %d \0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i32*
store i32 0, i32* %1
store i8* %5, i8** %6
store i32* %4, i32** %7
%8 = call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp ne i32* %9, null
br i1 %10, label %12, label %11
11: ; preds = %0
store i32 1, i32* %1
br label %39
12: ; preds = %0
br label %13
13: ; preds = %12, %34
%14 = load i32*, i32** %2
%15 = call i64 @feof(i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
br label %36
18: ; preds = %13
%19 = load i32*, i32** %2
%20 = load i8*, i8** %6
%21 = load i32*, i32** %7
%22 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %20, i32* %21)
store i32 0, i32* %3
br label %23
23: ; preds = %31, %18
%24 = load i32, i32* %3
%25 = load i32*, i32** %7
%26 = load i32, i32* %25
%27 = icmp slt i32 %24, %26
br i1 %27, label %28, label %34
28: ; preds = %23
%29 = load i8*, i8** %6
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %23
34: ; preds = %23
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %13
36: ; preds = %17
%37 = load i32*, i32** %2
%38 = call i32 @fclose(i32* %37)
store i32 0, i32* %1
br label %39
39: ; preds = %36, %11
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@.str = [30 x i8] c"/root/practica2/Entrada2b.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"%s %d \0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %25, label %6
6: ; preds = %0
%7 = call i64 @feof(i32* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %23
9: ; preds = %6, %19
%10 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %2, i32* %1)
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %9, %13
%14 = phi i32 [ %16, %13 ], [ 0, %9 ]
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%16 = add nuw nsw i32 %14, 1
%17 = load i32, i32* %1
%18 = icmp slt i32 %16, %17
br i1 %18, label %13, label %19
19: ; preds = %13, %9
%20 = call i32 @putchar(i32 10)
%21 = call i64 @feof(i32* %4)
%22 = icmp eq i64 %21, 0
br i1 %22, label %9, label %23
23: ; preds = %19, %6
%24 = call i32 @fclose(i32* %4)
br label %25
25: ; preds = %0, %23
%26 = phi i32 [ 0, %23 ], [ 1, %0 ]
ret i32 %26
}