#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*/ EXIT_FAILURE;
int /*<<< orphan*/ detect_tags_file();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, int /*<<< orphan*/);
void tag_id(char *id) {
  char file_name[30] = "/ctf_ucon2/";
  FILE *file = NULL;
  printf("Tagging level now...\n");
  sleep(0);
  strcat(file_name, detect_tags_file());
  file = fopen(file_name, "a");
  if (file != NULL) {
    if (fprintf(file, "%s\n", id) != 5) {
      printf("[FAIL] Failed to tag the level\n\n");
      exit(EXIT_FAILURE);
    } else {
    }
    fclose(file);
  }
  return;
}


x86 assembly (clang, -O0):
<tag_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xe6d(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe6a(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe67(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe65(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xe5f(%rip),%ax
mov    %ax,-0x14(%rbp)
movq   $0x0,-0x38(%rbp)
lea    0xe4e(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <sleep@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1040 <detect_tags_file@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1080 <strcat@plt>
lea    -0x30(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     125a <tag_id+0xda>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe12(%rip),%rsi
call   1060 <fprintf@plt>
cmp    $0x5,%eax
je     124c <tag_id+0xcc>
lea    0xe01(%rip),%rdi
call   1050 <printf@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    1251 <tag_id+0xd1>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tag_id>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r14
movups 0xe7d(%rip),%xmm0
movups %xmm0,0xe(%rsp)
movaps 0xe63(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10a0 <sleep@plt>
xor    %eax,%eax
call   1050 <detect_tags_file@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1080 <strcat@plt>
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     11fe <tag_id+0x7e>
mov    %rax,%rbx
lea    0xe3a(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1060 <fprintf@plt>
cmp    $0x5,%eax
jne    1206 <tag_id+0x86>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe2c(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@__const.tag_id.file_name = [30 x i8] c"/ctf_ucon2/\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [22 x i8] c"Tagging level now...\0A\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [33 x i8] c"[FAIL] Failed to tag the level\0A\0A\00"
@EXIT_FAILURE = global i32 0
define void @tag_id(i8* %0) {
%2 = alloca i8*
%3 = alloca [30 x i8]
%4 = alloca i32*
store i8* %0, i8** %2
%5 = bitcast [30 x i8]* %3 to i8*
store i32* null, i32** %4
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @sleep(i32 0)
%8 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%9 = call i32 (...) @detect_tags_file()
%10 = call i32 @strcat(i8* %8, i32 %9)
%11 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %4
%13 = load i32*, i32** %4
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %28
15: ; preds = %1
%16 = load i32*, i32** %4
%17 = load i8*, i8** %2
%18 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = icmp ne i32 %18, 5
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %15
br label %25
25: ; preds = %24
%26 = load i32*, i32** %4
%27 = call i32 @fclose(i32* %26)
br label %28
28: ; preds = %25, %1
ret void
}

LLVM IR (-O2):
@__const.tag_id.file_name = [30 x i8] c"/ctf_ucon2/\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@EXIT_FAILURE = global i32 0
@str = [21 x i8] c"Tagging level now...\00"
@str.4 = [32 x i8] c"[FAIL] Failed to tag the level\0A\00"
define void @tag_id(i8* %0) {
%2 = alloca [30 x i8]
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @sleep(i32 0)
%6 = tail call i32 (...) @detect_tags_file()
%7 = call i32 @strcat(i8* %3, i32 %6)
%8 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %19, label %10
10: ; preds = %1
%11 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%12 = icmp eq i32 %11, 5
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.4, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %10
%18 = call i32 @fclose(i32* %8)
br label %19
19: ; preds = %17, %1
ret void
}