#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 */
char *ndb_unix_getCodepage();
int /*<<< orphan*/ strcpy(char *, char *);
char *ndb_osdep_getCodepage() {
  static char codepage[50] = "\0";
  char *codepage_os = NULL;
  if (codepage[0] != '\0')
    return codepage;
  codepage_os = ndb_unix_getCodepage();
  if (codepage_os == NULL)
    strcpy(codepage, "");
  else
    strcpy(codepage, codepage_os);
  return codepage;
}


x86 assembly (clang, -O0):
<ndb_osdep_getCodepage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x10(%rbp)
movsbl 0x2f09(%rip),%eax
cmp    $0x0,%eax
je     1150 <ndb_osdep_getCodepage+0x30>
lea    0x2ef9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1199 <ndb_osdep_getCodepage+0x79>
mov    $0x0,%al
call   1030 <ndb_unix_getCodepage@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117e <ndb_osdep_getCodepage+0x5e>
lea    0x2ed3(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1040 <strcpy@plt>
jmp    118e <ndb_osdep_getCodepage+0x6e>
mov    -0x10(%rbp),%rsi
lea    0x2eb7(%rip),%rdi
call   1040 <strcpy@plt>
lea    0x2eab(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ndb_osdep_getCodepage>:
push   %rax
cmpb   $0x0,0x2f18(%rip)
jne    114e <ndb_osdep_getCodepage+0x2e>
xor    %eax,%eax
call   1030 <ndb_unix_getCodepage@plt>
lea    0x2f08(%rip),%rdi
test   %rax,%rax
je     1142 <ndb_osdep_getCodepage+0x22>
mov    %rax,%rsi
jmp    1149 <ndb_osdep_getCodepage+0x29>
lea    0xeb7(%rip),%rsi
call   1040 <strcpy@plt>
lea    0x2eeb(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@ndb_osdep_getCodepage.codepage = internal global [50 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
define i8* @ndb_osdep_getCodepage() {
%1 = alloca i8*
%2 = alloca i8*
store i8* null, i8** %2
%3 = load i8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @ndb_osdep_getCodepage.codepage, i64 0, i64 0)
%4 = sext i8 %3 to i32
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
store i8* getelementptr inbounds ([50 x i8], [50 x i8]* @ndb_osdep_getCodepage.codepage, i64 0, i64 0), i8** %1
br label %17
7: ; preds = %0
%8 = call i8* (...) @ndb_unix_getCodepage()
store i8* %8, i8** %2
%9 = load i8*, i8** %2
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @strcpy(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @ndb_osdep_getCodepage.codepage, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %16
13: ; preds = %7
%14 = load i8*, i8** %2
%15 = call i32 @strcpy(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @ndb_osdep_getCodepage.codepage, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13, %11
store i8* getelementptr inbounds ([50 x i8], [50 x i8]* @ndb_osdep_getCodepage.codepage, i64 0, i64 0), i8** %1
br label %17
17: ; preds = %16, %6
%18 = load i8*, i8** %1
ret i8* %18
}

LLVM IR (-O2):
@ndb_osdep_getCodepage.codepage = internal global [50 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
define i8* @ndb_osdep_getCodepage() {
%1 = load i8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @ndb_osdep_getCodepage.codepage, i64 0, i64 0)
%2 = icmp eq i8 %1, 0
br i1 %2, label %3, label %10
3: ; preds = %0
%4 = tail call i8* (...) @ndb_unix_getCodepage()
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @strcpy(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @ndb_osdep_getCodepage.codepage, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %10
8: ; preds = %3
%9 = tail call i32 @strcpy(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @ndb_osdep_getCodepage.codepage, i64 0, i64 0), i8* %4)
br label %10
10: ; preds = %6, %8, %0
ret i8* getelementptr inbounds ([50 x i8], [50 x i8]* @ndb_osdep_getCodepage.codepage, i64 0, i64 0)
}