#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*/ id_file_c;

/* Variables and functions */
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *get_event_file_path(int id_file) {
  char id_file_c[4];
  snprintf(id_file_c, sizeof(id_file_c), "%d", id_file);
  char *partial_path = "/dev/input/event";
  char *complete_path =
      (char *)malloc(strlen(partial_path) + strlen(id_file_c));
  strcpy(complete_path, partial_path);
  strcat(complete_path, id_file_c);
  return complete_path;
}


x86 assembly (clang, -O0):
<get_event_file_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0x4,%esi
lea    0xe92(%rip),%rdx
call   1050 <snprintf@plt>
lea    0xe89(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
add    %rax,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_event_file_path>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ecx
lea    0xea3(%rip),%rdx
lea    0x4(%rsp),%r14
mov    %r14,%rdi
mov    $0x4,%esi
call   1050 <snprintf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x10(%rax),%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe79(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [17 x i8] c"/dev/input/event\00"
define i8* @get_event_file_path(i32 %0) {
%2 = alloca i32
%3 = alloca [4 x i8]
%4 = alloca i8*
%5 = alloca i8*
store i32 %0, i32* %2
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* %2
%8 = call i32 @snprintf(i8* %6, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %4
%9 = load i8*, i8** %4
%10 = call i64 @strlen(i8* %9)
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%12 = call i64 @strlen(i8* %11)
%13 = add nsw i64 %10, %12
%14 = call i64 @malloc(i64 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = load i8*, i8** %4
%18 = call i32 @strcpy(i8* %16, i8* %17)
%19 = load i8*, i8** %5
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%21 = call i32 @strcat(i8* %19, i8* %20)
%22 = load i8*, i8** %5
ret i8* %22
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [17 x i8] c"/dev/input/event\00"
define i8* @get_event_file_path(i32 %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%4 = call i32 @snprintf(i8* %3, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = call i64 @strlen(i8* %3)
%6 = add nsw i64 %5, 16
%7 = call i64 @malloc(i64 %6)
%8 = inttoptr i64 %7 to i8*
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @strcat(i8* %8, i8* %3)
ret i8* %8
}