#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 /*<<< orphan*/ sscanf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int retorna_funcao(char *s) {
  char comando[4096];
  sscanf(s, "%s", comando);
  if (strcmp(comando, "USER") == 0)
    return 1;
  if (strcmp(comando, "PASS") == 0)
    return 2;
  if (strcmp(comando, "QUIT") == 0)
    return 3;
  if (strcmp(comando, "SYST") == 0)
    return 4;
  if (strcmp(comando, "PASV") == 0)
    return 5;
  if (strcmp(comando, "LIST") == 0)
    return 6;
  if (strcmp(comando, "RETR") == 0)
    return 7;
  if (strcmp(comando, "TYPE") == 0)
    return 8;
  if (strcmp(comando, "STOR") == 0)
    return 9;
  return -1;
}


x86 assembly (clang, -O0):
<retorna_funcao>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1010(%rbp),%rdx
lea    0xebf(%rip),%rsi
call   1040 <sscanf@plt>
lea    -0x1010(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    116f <retorna_funcao+0x4f>
movl   $0x1,-0x4(%rbp)
jmp    12be <retorna_funcao+0x19e>
lea    -0x1010(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1198 <retorna_funcao+0x78>
movl   $0x2,-0x4(%rbp)
jmp    12be <retorna_funcao+0x19e>
lea    -0x1010(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11c1 <retorna_funcao+0xa1>
movl   $0x3,-0x4(%rbp)
jmp    12be <retorna_funcao+0x19e>
lea    -0x1010(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ea <retorna_funcao+0xca>
movl   $0x4,-0x4(%rbp)
jmp    12be <retorna_funcao+0x19e>
lea    -0x1010(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1213 <retorna_funcao+0xf3>
movl   $0x5,-0x4(%rbp)
jmp    12be <retorna_funcao+0x19e>
lea    -0x1010(%rbp),%rdi
lea    0xdfb(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    123c <retorna_funcao+0x11c>
movl   $0x6,-0x4(%rbp)
jmp    12be <retorna_funcao+0x19e>
lea    -0x1010(%rbp),%rdi
lea    0xdd7(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1265 <retorna_funcao+0x145>
movl   $0x7,-0x4(%rbp)
jmp    12be <retorna_funcao+0x19e>
lea    -0x1010(%rbp),%rdi
lea    0xdb3(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    128e <retorna_funcao+0x16e>
movl   $0x8,-0x4(%rbp)
jmp    12be <retorna_funcao+0x19e>
lea    -0x1010(%rbp),%rdi
lea    0xd8f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    12b7 <retorna_funcao+0x197>
movl   $0x9,-0x4(%rbp)
jmp    12be <retorna_funcao+0x19e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<retorna_funcao>:
push   %rbx
sub    $0x1000,%rsp
lea    0xed1(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdx
call   1040 <sscanf@plt>
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ff <retorna_funcao+0xdf>
lea    0xeaf(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1206 <retorna_funcao+0xe6>
lea    0xe9c(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     120d <retorna_funcao+0xed>
lea    0xe89(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1214 <retorna_funcao+0xf4>
lea    0xe7a(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     121b <retorna_funcao+0xfb>
lea    0xe6b(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1222 <retorna_funcao+0x102>
lea    0xe5c(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1229 <retorna_funcao+0x109>
lea    0xe4d(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1230 <retorna_funcao+0x110>
lea    0xe3e(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
neg    %rax
sbb    %eax,%eax
or     $0x9,%eax
jmp    1235 <retorna_funcao+0x115>
mov    $0x1,%eax
jmp    1235 <retorna_funcao+0x115>
mov    $0x2,%eax
jmp    1235 <retorna_funcao+0x115>
mov    $0x3,%eax
jmp    1235 <retorna_funcao+0x115>
mov    $0x4,%eax
jmp    1235 <retorna_funcao+0x115>
mov    $0x5,%eax
jmp    1235 <retorna_funcao+0x115>
mov    $0x6,%eax
jmp    1235 <retorna_funcao+0x115>
mov    $0x7,%eax
jmp    1235 <retorna_funcao+0x115>
mov    $0x8,%eax
add    $0x1000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [5 x i8] c"PASS\00"
@.str.3 = [5 x i8] c"QUIT\00"
@.str.4 = [5 x i8] c"SYST\00"
@.str.5 = [5 x i8] c"PASV\00"
@.str.6 = [5 x i8] c"LIST\00"
@.str.7 = [5 x i8] c"RETR\00"
@.str.8 = [5 x i8] c"TYPE\00"
@.str.9 = [5 x i8] c"STOR\00"
define i32 @retorna_funcao(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [4096 x i8]
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%7 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 1, i32* %2
br label %53
12: ; preds = %1
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 2, i32* %2
br label %53
17: ; preds = %12
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 3, i32* %2
br label %53
22: ; preds = %17
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 4, i32* %2
br label %53
27: ; preds = %22
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 5, i32* %2
br label %53
32: ; preds = %27
%33 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 6, i32* %2
br label %53
37: ; preds = %32
%38 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %37
store i32 7, i32* %2
br label %53
42: ; preds = %37
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42
store i32 8, i32* %2
br label %53
47: ; preds = %42
%48 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%49 = call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %47
store i32 9, i32* %2
br label %53
52: ; preds = %47
store i32 -1, i32* %2
br label %53
53: ; preds = %52, %51, %46, %41, %36, %31, %26, %21, %16, %11
%54 = load i32, i32* %2
ret i32 %54
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [5 x i8] c"PASS\00"
@.str.3 = [5 x i8] c"QUIT\00"
@.str.4 = [5 x i8] c"SYST\00"
@.str.5 = [5 x i8] c"PASV\00"
@.str.6 = [5 x i8] c"LIST\00"
@.str.7 = [5 x i8] c"RETR\00"
@.str.8 = [5 x i8] c"TYPE\00"
@.str.9 = [5 x i8] c"STOR\00"
define i32 @retorna_funcao(i8* nocapture %0) {
%2 = alloca [4096 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%4 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %32, label %7
7: ; preds = %1
%8 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %32, label %10
10: ; preds = %7
%11 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %32, label %13
13: ; preds = %10
%14 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %32, label %16
16: ; preds = %13
%17 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %32, label %19
19: ; preds = %16
%20 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %32, label %22
22: ; preds = %19
%23 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %22
%26 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
%31 = select i1 %30, i32 9, i32 -1
br label %32
32: ; preds = %28, %25, %22, %19, %16, %13, %10, %7, %1
%33 = phi i32 [ 1, %1 ], [ 2, %7 ], [ 3, %10 ], [ 4, %13 ], [ 5, %16 ], [ 6, %19 ], [ 7, %22 ], [ 8, %25 ], [ %31, %28 ]
ret i32 %33
}