#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 PAPI_event_code_to_name(int, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void papif_event_code_to_name(int *EventCode, char *out_str, int *check,
                              int out_len) {
  char tmp[128];
  int i;
  *check = PAPI_event_code_to_name(*EventCode, tmp);
  strncpy(out_str, tmp, out_len);
  for (i = strlen(tmp); i < out_len; out_str[i++] = ' ')
    ;
}


x86 assembly (clang, -O0):
<papif_event_code_to_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    -0xa0(%rbp),%rsi
call   1050 <PAPI_event_code_to_name@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncpy@plt>
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11be <papif_event_code_to_name+0x8e>
jmp    119d <papif_event_code_to_name+0x6d>
mov    -0x10(%rbp),%rax
mov    -0xa4(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0xa4(%rbp)
movslq %ecx,%rcx
movb   $0x20,(%rax,%rcx,1)
jmp    1189 <papif_event_code_to_name+0x59>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<papif_event_code_to_name>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    (%rdi),%edi
mov    %rsp,%r15
mov    %r15,%rsi
call   1060 <PAPI_event_code_to_name@plt>
mov    %eax,(%rbx)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    %ebp,%eax
jge    119b <papif_event_code_to_name+0x5b>
movslq %eax,%rcx
add    %rcx,%r14
not    %eax
add    %ebp,%eax
add    $0x1,%rax
mov    %r14,%rdi
mov    $0x20,%esi
mov    %rax,%rdx
call   1050 <memset@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @papif_event_code_to_name(i32* %0, i8* %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [128 x i8]
%10 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%11 = load i32*, i32** %5
%12 = load i32, i32* %11
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%14 = call i32 @PAPI_event_code_to_name(i32 %12, i8* %13)
%15 = load i32*, i32** %7
store i32 %14, i32* %15
%16 = load i8*, i8** %6
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%18 = load i32, i32* %8
%19 = call i32 @strncpy(i8* %16, i8* %17, i32 %18)
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %10
br label %22
22: ; preds = %27, %4
%23 = load i32, i32* %10
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %33
26: ; preds = %22
br label %27
27: ; preds = %26
%28 = load i8*, i8** %6
%29 = load i32, i32* %10
%30 = add nsw i32 %29, 1
store i32 %30, i32* %10
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
store i8 32, i8* %32
br label %22
33: ; preds = %22
ret void
}

LLVM IR (-O2):
define void @papif_event_code_to_name(i32* nocapture %0, i8* %1, i32* nocapture writeonly %2, i32 %3) {
%5 = alloca [128 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%7 = load i32, i32* %0
%8 = call i32 @PAPI_event_code_to_name(i32 %7, i8* %6)
store i32 %8, i32* %2
%9 = call i32 @strncpy(i8* %1, i8* %6, i32 %3)
%10 = call i32 @strlen(i8* %6)
%11 = icmp slt i32 %10, %3
br i1 %11, label %12, label %19
12: ; preds = %4
%13 = sext i32 %10 to i64
%14 = getelementptr i8, i8* %1, i64 %13
%15 = xor i32 %10, -1
%16 = add i32 %15, %3
%17 = zext i32 %16 to i64
%18 = add nuw nsw i64 %17, 1
br label %19
19: ; preds = %12, %4
ret void
}