#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*/ sprintf(char *, char *, int);
const char *sec_errstr(int err) {
  static int bufnum = 0;
  static char buf[2][20];
  bufnum = bufnum ? 0 : 1;
  sprintf(buf[bufnum], "0x%X", err);
  return buf[bufnum];
}


x86 assembly (clang, -O0):
<sec_errstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2f1f(%rip),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,0x2f0c(%rip)
movslq 0x2f05(%rip),%rax
lea    0x2f0e(%rip),%rdi
imul   $0x14,%rax,%rax
add    %rax,%rdi
mov    -0x4(%rbp),%edx
lea    0xead(%rip),%rsi
call   1030 <sprintf@plt>
movslq 0x2ee1(%rip),%rcx
lea    0x2eea(%rip),%rax
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sec_errstr>:
push   %rbx
mov    %edi,%edx
xor    %eax,%eax
cmpl   $0x0,0x2f24(%rip)
sete   %al
mov    %eax,0x2f1b(%rip)
lea    (%rax,%rax,4),%rax
lea    0x2f20(%rip),%rbx
lea    (%rbx,%rax,4),%rdi
lea    0xec5(%rip),%rsi
call   1030 <sprintf@plt>
mov    0x2efa(%rip),%eax
lea    (%rax,%rax,4),%rax
lea    (%rbx,%rax,4),%rax
pop    %rbx
ret

LLVM IR (-O0):
@sec_errstr.bufnum = internal global i32 0
@sec_errstr.buf = internal global [2 x [20 x i8]] zeroinitializer
@.str = [5 x i8] c"0x%X\00"
define i8* @sec_errstr(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* @sec_errstr.bufnum
%4 = icmp ne i32 %3, 0
%5 = zext i1 %4 to i64
%6 = select i1 %4, i32 0, i32 1
store i32 %6, i32* @sec_errstr.bufnum
%7 = load i32, i32* @sec_errstr.bufnum
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [2 x [20 x i8]], [2 x [20 x i8]]* @sec_errstr.buf, i64 0, i64 %8
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%11 = load i32, i32* %2
%12 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @sec_errstr.bufnum
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [2 x [20 x i8]], [2 x [20 x i8]]* @sec_errstr.buf, i64 0, i64 %14
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %15, i64 0, i64 0
ret i8* %16
}

LLVM IR (-O2):
@sec_errstr.bufnum = internal unnamed_addr global i32 0
@sec_errstr.buf = internal global [2 x [20 x i8]] zeroinitializer
@.str = [5 x i8] c"0x%X\00"
define i8* @sec_errstr(i32 %0) {
%2 = load i32, i32* @sec_errstr.bufnum
%3 = icmp eq i32 %2, 0
%4 = zext i1 %3 to i32
store i32 %4, i32* @sec_errstr.bufnum
%5 = zext i1 %3 to i64
%6 = getelementptr inbounds [2 x [20 x i8]], [2 x [20 x i8]]* @sec_errstr.buf, i64 0, i64 %5, i64 0
%7 = tail call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %0)
%8 = load i32, i32* @sec_errstr.bufnum
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds [2 x [20 x i8]], [2 x [20 x i8]]* @sec_errstr.buf, i64 0, i64 %9, i64 0
ret i8* %10
}