#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 */
float log(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int r, i, a, b, n, rodada[1001], vPedro = 0, vLucas = 0;
  float lucas, pedro;
  scanf("%d", &r);
  for (i = 1; i <= r; i++) {
    scanf("%d^%d", &a, &b);
    scanf("%d!", &n);
    lucas = log(a) * b;
    for (pedro = log(1); n > 1; n--)
      pedro += log(n);
    if (lucas > pedro) {
      rodada[i] = 1;
      vLucas++;
    } else {
      rodada[i] = 2;
      vPedro++;
    }
  }
  if (vPedro == vLucas)
    printf("A competicao terminou empatada!\n");
  else if (vLucas > vPedro)
    printf("Campeao: Lucas!\n");
  else
    printf("Campeao: Pedro!\n");
  for (i = 1; i <= r; i++) {
    if (rodada[i] == 1)
      printf("Rodada #%d: Lucas foi o vencedor\n", i);
    else
      printf("Rodada #%d: Pedro foi o vencedor\n", i);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfd0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xfc4(%rbp)
movl   $0x0,-0xfc8(%rbp)
lea    0xea6(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1267 <main+0x137>
lea    0xe7e(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe6e(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%edi
call   1050 <log@plt>
cvtsi2ssl -0x14(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0xfcc(%rbp)
ff
mov    $0x1,%edi
call   1050 <log@plt>
movss  %xmm0,-0xfd0(%rbp)
ff
cmpl   $0x1,-0x18(%rbp)
jle    11fe <main+0xce>
mov    -0x18(%rbp),%edi
call   1050 <log@plt>
addss  -0xfd0(%rbp),%xmm0
ff
movss  %xmm0,-0xfd0(%rbp)
ff
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    11ce <main+0x9e>
movss  -0xfcc(%rbp),%xmm0
ff
ucomiss -0xfd0(%rbp),%xmm0
jbe    1236 <main+0x106>
movslq -0xc(%rbp),%rax
movl   $0x1,-0xfc0(%rbp,%rax,4)
mov    -0xfc8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc8(%rbp)
jmp    1254 <main+0x124>
movslq -0xc(%rbp),%rax
movl   $0x2,-0xfc0(%rbp,%rax,4)
mov    -0xfc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc4(%rbp)
jmp    1259 <main+0x129>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116f <main+0x3f>
mov    -0xfc4(%rbp),%eax
cmp    -0xfc8(%rbp),%eax
jne    128c <main+0x15c>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c4 <main+0x194>
mov    -0xfc8(%rbp),%eax
cmp    -0xfc4(%rbp),%eax
jle    12b1 <main+0x181>
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12bf <main+0x18f>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c4 <main+0x194>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1323 <main+0x1f3>
movslq -0xc(%rbp),%rax
cmpl   $0x1,-0xfc0(%rbp,%rax,4)
01
jne    12ff <main+0x1cf>
mov    -0xc(%rbp),%esi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1310 <main+0x1e0>
mov    -0xc(%rbp),%esi
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1315 <main+0x1e5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12cb <main+0x19b>
mov    -0x4(%rbp),%eax
add    $0xfd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xfc8,%rsp
lea    0xeab(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf03(%rip),%rdi
cmpl   $0x0,0x4(%rsp)
jle    1288 <main+0x148>
mov    $0x1,%r14d
lea    0x18(%rsp),%r13
lea    0xe7e(%rip),%rbx
lea    0x8(%rsp),%rbp
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    11e0 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nop
movss  0x10(%rsp),%xmm0
mulss  0xc(%rsp),%xmm0
xor    %eax,%eax
xor    %ecx,%ecx
ucomiss %xmm1,%xmm0
setbe  %al
seta   %cl
mov    $0x2,%edx
sub    %ecx,%edx
add    %eax,%r12d
add    %ecx,%r15d
mov    %edx,0x20(%rsp,%r14,4)
lea    0x1(%r14),%rax
movslq 0x4(%rsp),%rcx
cmp    %rcx,%r14
mov    %rax,%r14
jge    126a <main+0x12a>
lea    0xe19(%rip),%rdi
lea    0x1c(%rsp),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x1c(%rsp),%edi
call   1060 <log@plt>
movss  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ssl 0x18(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x1,%edi
call   1060 <log@plt>
movaps %xmm0,%xmm1
mov    0x8(%rsp),%edi
cmp    $0x2,%edi
jl     11a0 <main+0x60>
nopl   0x0(%rax,%rax,1)
movss  %xmm1,0x14(%rsp)
call   1060 <log@plt>
movss  0x14(%rsp),%xmm1
addss  %xmm0,%xmm1
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%edi
mov    %edi,0x8(%rsp)
cmp    $0x2,%eax
jg     1240 <main+0x100>
jmp    11a0 <main+0x60>
cmp    %r15d,%r12d
lea    0xdfa(%rip),%rdi
je     1288 <main+0x148>
lea    0xde1(%rip),%rax
lea    0xdca(%rip),%rdi
cmovb  %rax,%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
jle    12d9 <main+0x199>
mov    $0x1,%ebx
lea    0xd6a(%rip),%rbp
lea    0xd85(%rip),%r14
jmp    12ca <main+0x18a>
nopl   0x0(%rax)
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%rbx),%rax
movslq 0x4(%rsp),%rcx
cmp    %rcx,%rbx
mov    %rax,%rbx
jge    12d9 <main+0x199>
cmpl   $0x1,0x20(%rsp,%rbx,4)
mov    %rbp,%rdi
je     12b0 <main+0x170>
mov    %r14,%rdi
jmp    12b0 <main+0x170>
xor    %eax,%eax
add    $0xfc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d^%d\00"
@.str.2 = [4 x i8] c"%d!\00"
@.str.3 = [33 x i8] c"A competicao terminou empatada!\0A\00"
@.str.4 = [17 x i8] c"Campeao: Lucas!\0A\00"
@.str.5 = [17 x i8] c"Campeao: Pedro!\0A\00"
@.str.6 = [34 x i8] c"Rodada #%d: Lucas foi o vencedor\0A\00"
@.str.7 = [34 x i8] c"Rodada #%d: Pedro foi o vencedor\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1001 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
%11 = alloca float
store i32 0, i32* %1
store i32 0, i32* %8
store i32 0, i32* %9
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %13
13: ; preds = %54, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %57
17: ; preds = %13
%18 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%19 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%20 = load i32, i32* %4
%21 = call float @log(i32 %20)
%22 = load i32, i32* %5
%23 = sitofp i32 %22 to float
%24 = fmul float %21, %23
store float %24, float* %10
%25 = call float @log(i32 1)
store float %25, float* %11
br label %26
26: ; preds = %34, %17
%27 = load i32, i32* %6
%28 = icmp sgt i32 %27, 1
br i1 %28, label %29, label %37
29: ; preds = %26
%30 = load i32, i32* %6
%31 = call float @log(i32 %30)
%32 = load float, float* %11
%33 = fadd float %32, %31
store float %33, float* %11
br label %34
34: ; preds = %29
%35 = load i32, i32* %6
%36 = add nsw i32 %35, -1
store i32 %36, i32* %6
br label %26
37: ; preds = %26
%38 = load float, float* %10
%39 = load float, float* %11
%40 = fcmp ogt float %38, %39
br i1 %40, label %41, label %47
41: ; preds = %37
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [1001 x i32], [1001 x i32]* %7, i64 0, i64 %43
store i32 1, i32* %44
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %53
47: ; preds = %37
%48 = load i32, i32* %3
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [1001 x i32], [1001 x i32]* %7, i64 0, i64 %49
store i32 2, i32* %50
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
store i32 %52, i32* %8
br label %53
53: ; preds = %47, %41
br label %54
54: ; preds = %53
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %13
57: ; preds = %13
%58 = load i32, i32* %8
%59 = load i32, i32* %9
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %72
63: ; preds = %57
%64 = load i32, i32* %9
%65 = load i32, i32* %8
%66 = icmp sgt i32 %64, %65
br i1 %66, label %67, label %69
67: ; preds = %63
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %71
69: ; preds = %63
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %71
71: ; preds = %69, %67
br label %72
72: ; preds = %71, %61
store i32 1, i32* %3
br label %73
73: ; preds = %90, %72
%74 = load i32, i32* %3
%75 = load i32, i32* %2
%76 = icmp sle i32 %74, %75
br i1 %76, label %77, label %93
77: ; preds = %73
%78 = load i32, i32* %3
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [1001 x i32], [1001 x i32]* %7, i64 0, i64 %79
%81 = load i32, i32* %80
%82 = icmp eq i32 %81, 1
br i1 %82, label %83, label %86
83: ; preds = %77
%84 = load i32, i32* %3
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 %84)
br label %89
86: ; preds = %77
%87 = load i32, i32* %3
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %87)
br label %89
89: ; preds = %86, %83
br label %90
90: ; preds = %89
%91 = load i32, i32* %3
%92 = add nsw i32 %91, 1
store i32 %92, i32* %3
br label %73
93: ; preds = %73
%94 = load i32, i32* %1
ret i32 %94
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d^%d\00"
@.str.2 = [4 x i8] c"%d!\00"
@.str.6 = [34 x i8] c"Rodada #%d: Lucas foi o vencedor\0A\00"
@.str.7 = [34 x i8] c"Rodada #%d: Pedro foi o vencedor\0A\00"
@str = [16 x i8] c"Campeao: Pedro!\00"
@str.8 = [16 x i8] c"Campeao: Lucas!\00"
@str.9 = [32 x i8] c"A competicao terminou empatada!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1001 x i32]
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast [1001 x i32]* %5 to i8*
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = icmp slt i32 %12, 1
br i1 %13, label %55, label %14
14: ; preds = %0, %36
%15 = phi i64 [ %46, %36 ], [ 1, %0 ]
%16 = phi i32 [ %44, %36 ], [ 0, %0 ]
%17 = phi i32 [ %42, %36 ], [ 0, %0 ]
%18 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%19 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%20 = load i32, i32* %2
%21 = call float @log(i32 %20)
%22 = load i32, i32* %3
%23 = sitofp i32 %22 to float
%24 = fmul float %21, %23
%25 = call float @log(i32 1)
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 1
br i1 %27, label %28, label %36
28: ; preds = %14, %28
%29 = phi float [ %32, %28 ], [ %25, %14 ]
%30 = phi i32 [ %34, %28 ], [ %26, %14 ]
%31 = call float @log(i32 %30)
%32 = fadd float %29, %31
%33 = load i32, i32* %4
%34 = add nsw i32 %33, -1
store i32 %34, i32* %4
%35 = icmp sgt i32 %33, 2
br i1 %35, label %28, label %36
36: ; preds = %28, %14
%37 = phi float [ %25, %14 ], [ %32, %28 ]
%38 = fcmp ogt float %24, %37
%39 = select i1 %38, i32 1, i32 2
%40 = xor i1 %38, true
%41 = zext i1 %40 to i32
%42 = add nuw nsw i32 %17, %41
%43 = zext i1 %38 to i32
%44 = add nuw nsw i32 %16, %43
%45 = getelementptr inbounds [1001 x i32], [1001 x i32]* %5, i64 0, i64 %15
store i32 %39, i32* %45
%46 = add nuw nsw i64 %15, 1
%47 = load i32, i32* %1
%48 = sext i32 %47 to i64
%49 = icmp slt i64 %15, %48
br i1 %49, label %14, label %50
50: ; preds = %36
%51 = icmp eq i32 %42, %44
br i1 %51, label %55, label %52
52: ; preds = %50
%53 = icmp ugt i32 %44, %42
%54 = select i1 %53, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0)
br label %55
55: ; preds = %52, %50, %0
%56 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0), %0 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0), %50 ], [ %54, %52 ]
%57 = call i32 @puts(i8* dereferenceable(1) %56)
%58 = load i32, i32* %1
%59 = icmp slt i32 %58, 1
br i1 %59, label %72, label %60
60: ; preds = %55, %60
%61 = phi i64 [ %68, %60 ], [ 1, %55 ]
%62 = getelementptr inbounds [1001 x i32], [1001 x i32]* %5, i64 0, i64 %61
%63 = load i32, i32* %62
%64 = icmp eq i32 %63, 1
%65 = trunc i64 %61 to i32
%66 = select i1 %64, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0)
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %66, i32 %65)
%68 = add nuw nsw i64 %61, 1
%69 = load i32, i32* %1
%70 = sext i32 %69 to i64
%71 = icmp slt i64 %61, %70
br i1 %71, label %60, label %72
72: ; preds = %60, %55
ret i32 0
}