#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int get_id(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(void) {
  char test_str_true[] = "toto_003", test_str_true2[] = "toto0.5_003",
       test_str_false[] = "toto0.5.dat", test_str_false2[] = "toto.dat";
  int val = get_id(test_str_true);
  if (val == -1) {
    fprintf(stderr, "\033[31mFAILED :\033[00m %s hasn't give any result!\n",
            test_str_true);
    return EXIT_FAILURE;
  } else if (val != 3) {
    fprintf(stderr, "\033[31mFAILED :\033[00m Found %d instead of 3!\n", val);
    return EXIT_FAILURE;
  }
  printf("\033[33mSUCCESS :\033[00m Found the correct value : %d (3)!\n", val);
  val = get_id(test_str_true2);
  if (val == -1) {
    fprintf(stderr, "\033[31mFAILED :\033[00m %s hasn't give any result!\n",
            test_str_true2);
    return EXIT_FAILURE;
  } else if (val != 3) {
    fprintf(stderr, "\033[31mFAILED :\033[00m Found %d instead of 3!\n", val);
    return EXIT_FAILURE;
  }
  printf("\033[33mSUCCESS :\033[00m Found the correct value : %d (3)!\n", val);
  val = get_id(test_str_false);
  if (val != -1) {
    fprintf(stderr, "\033[31mFAILED :\033[00m Found something with %s :: %d!\n",
            test_str_false, val);
    return EXIT_FAILURE;
  }
  printf("\033[33mSUCCESS :\033[00m Found the correct value : nothing!\n");
  val = get_id(test_str_false2);
  if (val != -1) {
    fprintf(stderr, "\033[31mFAILED :\033[00m Found something with %s :: %d!\n",
            test_str_false2, val);
    return EXIT_FAILURE;
  }
  printf("\033[33mSUCCESS :\033[00m Found the correct value : nothing!\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0xd(%rbp)
mov    0xeb8(%rip),%al
mov    %al,-0x5(%rbp)
mov    0xeaf(%rip),%rax
mov    %rax,-0x19(%rbp)
mov    0xead(%rip),%eax
mov    %eax,-0x11(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x25(%rbp)
mov    0xea5(%rip),%eax
mov    %eax,-0x1d(%rbp)
mov    0xe9f(%rip),%rax
mov    %rax,-0x2e(%rbp)
mov    0xe9d(%rip),%al
mov    %al,-0x26(%rbp)
lea    -0xd(%rbp),%rdi
call   1050 <get_id@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    11d1 <main+0xa1>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    -0xd(%rbp),%rdx
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    135b <main+0x22b>
cmpl   $0x3,-0x34(%rbp)
je     1206 <main+0xd6>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    135b <main+0x22b>
jmp    120b <main+0xdb>
mov    -0x34(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x19(%rbp),%rdi
call   1050 <get_id@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    125e <main+0x12e>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
lea    -0x19(%rbp),%rdx
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    135b <main+0x22b>
cmpl   $0x3,-0x34(%rbp)
je     1293 <main+0x163>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
lea    0xdde(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    135b <main+0x22b>
jmp    1298 <main+0x168>
mov    -0x34(%rbp),%esi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x25(%rbp),%rdi
call   1050 <get_id@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
je     12ee <main+0x1be>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
lea    -0x25(%rbp),%rdx
mov    -0x34(%rbp),%ecx
lea    0xde5(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2cf4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    135b <main+0x22b>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x2e(%rbp),%rdi
call   1050 <get_id@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
je     1341 <main+0x211>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
lea    -0x2e(%rbp),%rdx
mov    -0x34(%rbp),%ecx
lea    0xd92(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2ca1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    135b <main+0x22b>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2c7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
movabs $0x3330305f6f746f74,%rax
30 30 33
mov    %rax,0x18(%rsp)
movb   $0x0,0x20(%rsp)
movabs $0x5f352e306f746f74,%rax
2e 35 5f
mov    %rax,0x38(%rsp)
movl   $0x333030,0x40(%rsp)
movabs $0x2e352e306f746f74,%rax
2e 35 2e
mov    %rax,0x28(%rsp)
movl   $0x746164,0x30(%rsp)
movabs $0x7461642e6f746f74,%rax
64 61 74
mov    %rax,0x8(%rsp)
movb   $0x0,0x10(%rsp)
lea    0x18(%rsp),%rdi
call   1060 <get_id@plt>
cmp    $0x3,%eax
je     11c5 <main+0x85>
cmp    $0xffffffff,%eax
jne    120a <main+0xca>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
lea    0x18(%rsp),%rdx
jmp    1201 <main+0xc1>
lea    0xeb8(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x38(%rsp),%rdi
call   1060 <get_id@plt>
cmp    $0x3,%eax
je     1231 <main+0xf1>
cmp    $0xffffffff,%eax
jne    120a <main+0xca>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
lea    0x38(%rsp),%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1223 <main+0xe3>
mov    0x2dcf(%rip),%rcx
mov    (%rcx),%edi
lea    0xe3f(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
ret
lea    0xe4c(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x28(%rsp),%rdi
call   1060 <get_id@plt>
cmp    $0xffffffff,%eax
je     126a <main+0x12a>
mov    0x2d86(%rip),%rcx
mov    (%rcx),%edi
lea    0xe58(%rip),%rsi
lea    0x28(%rsp),%rdx
jmp    129a <main+0x15a>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rdi
call   1060 <get_id@plt>
cmp    $0xffffffff,%eax
je     12a8 <main+0x168>
mov    0x2d54(%rip),%rcx
mov    (%rcx),%edi
lea    0xe26(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1223 <main+0xe3>
lea    0xe3f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d15(%rip),%rax
jmp    122a <main+0xea>

LLVM IR (-O0):
@__const.main.test_str_true = [9 x i8] c"toto_003\00"
@__const.main.test_str_true2 = [12 x i8] c"toto0.5_003\00"
@__const.main.test_str_false = [12 x i8] c"toto0.5.dat\00"
@__const.main.test_str_false2 = [9 x i8] c"toto.dat\00"
@stderr = global i32 0
@.str = [47 x i8] c"\1B[31mFAILED :\1B[00m %s hasn't give any result!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [43 x i8] c"\1B[31mFAILED :\1B[00m Found %d instead of 3!\0A\00"
@.str.2 = [55 x i8] c"\1B[33mSUCCESS :\1B[00m Found the correct value : %d (3)!\0A\00"
@.str.3 = [51 x i8] c"\1B[31mFAILED :\1B[00m Found something with %s :: %d!\0A\00"
@.str.4 = [56 x i8] c"\1B[33mSUCCESS :\1B[00m Found the correct value : nothing!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i8]
%3 = alloca [12 x i8]
%4 = alloca [12 x i8]
%5 = alloca [9 x i8]
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [9 x i8]* %2 to i8*
%8 = bitcast [12 x i8]* %3 to i8*
%9 = bitcast [12 x i8]* %4 to i8*
%10 = bitcast [9 x i8]* %5 to i8*
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%12 = call i32 @get_id(i8* %11)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %20
15: ; preds = %0
%16 = load i32, i32* @stderr
%17 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
store i32 %19, i32* %1
br label %78
20: ; preds = %0
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 3
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = load i32, i32* %6
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @EXIT_FAILURE
store i32 %27, i32* %1
br label %78
28: ; preds = %20
br label %29
29: ; preds = %28
%30 = load i32, i32* %6
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%33 = call i32 @get_id(i8* %32)
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %41
36: ; preds = %29
%37 = load i32, i32* @stderr
%38 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %38)
%40 = load i32, i32* @EXIT_FAILURE
store i32 %40, i32* %1
br label %78
41: ; preds = %29
%42 = load i32, i32* %6
%43 = icmp ne i32 %42, 3
br i1 %43, label %44, label %49
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = load i32, i32* %6
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = load i32, i32* @EXIT_FAILURE
store i32 %48, i32* %1
br label %78
49: ; preds = %41
br label %50
50: ; preds = %49
%51 = load i32, i32* %6
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%54 = call i32 @get_id(i8* %53)
store i32 %54, i32* %6
%55 = load i32, i32* %6
%56 = icmp ne i32 %55, -1
br i1 %56, label %57, label %63
57: ; preds = %50
%58 = load i32, i32* @stderr
%59 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%60 = load i32, i32* %6
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %59, i32 %60)
%62 = load i32, i32* @EXIT_FAILURE
store i32 %62, i32* %1
br label %78
63: ; preds = %50
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0))
%65 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%66 = call i32 @get_id(i8* %65)
store i32 %66, i32* %6
%67 = load i32, i32* %6
%68 = icmp ne i32 %67, -1
br i1 %68, label %69, label %75
69: ; preds = %63
%70 = load i32, i32* @stderr
%71 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%72 = load i32, i32* %6
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %71, i32 %72)
%74 = load i32, i32* @EXIT_FAILURE
store i32 %74, i32* %1
br label %78
75: ; preds = %63
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0))
%77 = load i32, i32* @EXIT_SUCCESS
store i32 %77, i32* %1
br label %78
78: ; preds = %75, %69, %57, %44, %36, %23, %15
%79 = load i32, i32* %1
ret i32 %79
}

LLVM IR (-O2):
@__const.main.test_str_true = [9 x i8] c"toto_003\00"
@__const.main.test_str_true2 = [12 x i8] c"toto0.5_003\00"
@__const.main.test_str_false = [12 x i8] c"toto0.5.dat\00"
@__const.main.test_str_false2 = [9 x i8] c"toto.dat\00"
@stderr = global i32 0
@.str = [47 x i8] c"\1B[31mFAILED :\1B[00m %s hasn't give any result!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [43 x i8] c"\1B[31mFAILED :\1B[00m Found %d instead of 3!\0A\00"
@.str.2 = [55 x i8] c"\1B[33mSUCCESS :\1B[00m Found the correct value : %d (3)!\0A\00"
@.str.3 = [51 x i8] c"\1B[31mFAILED :\1B[00m Found something with %s :: %d!\0A\00"
@EXIT_SUCCESS = global i32 0
@str.5 = [55 x i8] c"\1B[33mSUCCESS :\1B[00m Found the correct value : nothing!\00"
define i32 @main() {
%1 = alloca [9 x i8]
%2 = alloca [12 x i8]
%3 = alloca [12 x i8]
%4 = alloca [9 x i8]
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%9 = call i32 @get_id(i8* %5)
switch i32 %9, label %13 [
i32 -1, label %10
i32 3, label %16
]
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %41
13: ; preds = %0
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %41
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i32 3)
%18 = call i32 @get_id(i8* %6)
switch i32 %18, label %22 [
i32 -1, label %19
i32 3, label %25
]
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %41
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %41
25: ; preds = %16
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i32 3)
%27 = call i32 @get_id(i8* %7)
%28 = icmp eq i32 %27, -1
br i1 %28, label %32, label %29
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %7, i32 %27)
br label %41
32: ; preds = %25
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.5, i64 0, i64 0))
%34 = call i32 @get_id(i8* %8)
%35 = icmp eq i32 %34, -1
br i1 %35, label %39, label %36
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %8, i32 %34)
br label %41
39: ; preds = %32
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.5, i64 0, i64 0))
br label %41
41: ; preds = %39, %36, %29, %22, %19, %13, %10
%42 = phi i32* [ @EXIT_FAILURE, %10 ], [ @EXIT_FAILURE, %13 ], [ @EXIT_FAILURE, %19 ], [ @EXIT_FAILURE, %22 ], [ @EXIT_FAILURE, %29 ], [ @EXIT_FAILURE, %36 ], [ @EXIT_SUCCESS, %39 ]
%43 = load i32, i32* %42
ret i32 %43
}