#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 */
int atoi(char *);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ setToken(char *, int, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void truco(char mensagem[32], char *valorRodada) {
  int rodada;
  char aux[2];
  rodada = atoi(valorRodada);
  if (rodada == 1) {
    rodada = 3;
  } else if (rodada == 3) {
    rodada = 6;
  } else if (rodada == 6) {
    rodada = 9;
  } else if (rodada == 9) {
    rodada = 12;
  }
  bzero(valorRodada, 3);
  sprintf(aux, "%d", rodada);
  if (rodada >= 10) {
    strcat(valorRodada, aux);
    setToken(mensagem, 17, 18, aux);
  } else {
    strcpy(valorRodada, "0");
    strcat(valorRodada, aux);
    setToken(mensagem, 17, 18, valorRodada);
  }
}


x86 assembly (clang, -O0):
<truco>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1192 <truco+0x32>
movl   $0x3,-0x14(%rbp)
jmp    11de <truco+0x7e>
cmpl   $0x3,-0x14(%rbp)
jne    11a8 <truco+0x48>
movl   $0x6,-0x14(%rbp)
jmp    11d9 <truco+0x79>
cmpl   $0x6,-0x14(%rbp)
jne    11be <truco+0x5e>
movl   $0x9,-0x14(%rbp)
jmp    11d4 <truco+0x74>
cmpl   $0x9,-0x14(%rbp)
jne    11cf <truco+0x6f>
movl   $0xc,-0x14(%rbp)
jmp    11d4 <truco+0x74>
jmp    11d9 <truco+0x79>
jmp    11de <truco+0x7e>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1050 <bzero@plt>
lea    -0x16(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe06(%rip),%rsi
call   1080 <sprintf@plt>
cmpl   $0xa,-0x14(%rbp)
jl     1232 <truco+0xd2>
mov    -0x10(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x16(%rbp),%rcx
mov    $0x11,%esi
mov    $0x12,%edx
call   1040 <setToken@plt>
jmp    1266 <truco+0x106>
mov    -0x10(%rbp),%rdi
lea    0xdc6(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x11,%esi
mov    $0x12,%edx
call   1040 <setToken@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<truco>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
add    $0xffffffff,%eax
cmp    $0x8,%eax
ja     1196 <truco+0x36>
mov    $0x125,%ecx
bt     %eax,%ecx
jae    1196 <truco+0x36>
cltq
lea    0xe75(%rip),%rcx
mov    (%rcx,%rax,4),%ebp
mov    %rbx,%rdi
mov    $0x3,%esi
call   1050 <bzero@plt>
lea    0xe56(%rip),%rsi
lea    0xe(%rsp),%rdi
mov    %ebp,%edx
call   1080 <sprintf@plt>
cmp    $0xa,%ebp
jl     11dd <truco+0x7d>
lea    0xe(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %r14,%rdi
mov    $0x11,%esi
mov    $0x12,%edx
mov    %rbp,%rcx
jmp    1209 <truco+0xa9>
lea    0xe1f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %r14,%rdi
mov    $0x11,%esi
mov    $0x12,%edx
mov    %rbx,%rcx
call   1040 <setToken@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"0\00"
define void @truco(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [2 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @atoi(i8* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 3, i32* %5
br label %27
12: ; preds = %2
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 3
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 6, i32* %5
br label %26
16: ; preds = %12
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 6
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 9, i32* %5
br label %25
20: ; preds = %16
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 9
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 12, i32* %5
br label %24
24: ; preds = %23, %20
br label %25
25: ; preds = %24, %19
br label %26
26: ; preds = %25, %15
br label %27
27: ; preds = %26, %11
%28 = load i8*, i8** %4
%29 = call i32 @bzero(i8* %28, i32 3)
%30 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%31 = load i32, i32* %5
%32 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %5
%34 = icmp sge i32 %33, 10
br i1 %34, label %35, label %42
35: ; preds = %27
%36 = load i8*, i8** %4
%37 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%38 = call i32 @strcat(i8* %36, i8* %37)
%39 = load i8*, i8** %3
%40 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%41 = call i32 @setToken(i8* %39, i32 17, i32 18, i8* %40)
br label %51
42: ; preds = %27
%43 = load i8*, i8** %4
%44 = call i32 @strcpy(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%45 = load i8*, i8** %4
%46 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%47 = call i32 @strcat(i8* %45, i8* %46)
%48 = load i8*, i8** %3
%49 = load i8*, i8** %4
%50 = call i32 @setToken(i8* %48, i32 17, i32 18, i8* %49)
br label %51
51: ; preds = %42, %35
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"0\00"
@switch.table.truco = [9 x i32] [i32 3, i32 3, i32 6, i32 3, i32 3, i32 9, i32 3, i32 3, i32 12]
define void @truco(i8* %0, i8* %1) {
%3 = alloca [2 x i8]
%4 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @atoi(i8* %1)
%6 = add i32 %5, -1
%7 = icmp ult i32 %6, 9
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = trunc i32 %6 to i16
%10 = lshr i16 293, %9
%11 = and i16 %10, 1
%12 = icmp eq i16 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = sext i32 %6 to i64
%15 = getelementptr inbounds [9 x i32], [9 x i32]* @switch.table.truco, i64 0, i64 %14
%16 = load i32, i32* %15
br label %17
17: ; preds = %2, %8, %13
%18 = phi i32 [ %16, %13 ], [ %5, %8 ], [ %5, %2 ]
%19 = tail call i32 @bzero(i8* %1, i32 3)
%20 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
%21 = icmp sgt i32 %18, 9
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = call i32 @strcat(i8* %1, i8* %4)
%24 = call i32 @setToken(i8* %0, i32 17, i32 18, i8* %4)
br label %29
25: ; preds = %17
%26 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @strcat(i8* %1, i8* %4)
%28 = call i32 @setToken(i8* %0, i32 17, i32 18, i8* %1)
br label %29
29: ; preds = %25, %22
ret void
}