#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*/ RTLD_LAZY;
char *dlerror();
void *dlopen(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
void pyobjc_internal_init() {
  static void *foundation = NULL;
  if (foundation == NULL) {
    foundation = dlopen("/System/Library/Frameworks/Foundation.framework/"
                        "Versions/Current/Foundation",
                        RTLD_LAZY);
    if (foundation == NULL) {
      char *msg = dlerror();
      printf("Got dlopen error on Foundation: %s\n", msg);
      foundation = dlopen("/Groups/System/Library/Frameworks/"
                          "Foundation.framework/Versions/Current/Foundation",
                          RTLD_LAZY);
      if (foundation == NULL) {
        msg = dlerror();
        printf("Got fallback dlopen error on Foundation: %s\n", msg);
        return;
      }
    }
  }
}


x86 assembly (clang, -O0):
<pyobjc_internal_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpq   $0x0,0x2f00(%rip)
jne    11df <pyobjc_internal_init+0xaf>
mov    0x2e93(%rip),%rax
mov    (%rax),%esi
lea    0xed5(%rip),%rdi
call   1050 <dlopen@plt>
mov    %rax,0x2ede(%rip)
cmpq   $0x0,0x2ed6(%rip)
jne    11da <pyobjc_internal_init+0xaa>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
lea    0xe89(%rip),%rdi
call   1050 <dlopen@plt>
mov    %rax,0x2e99(%rip)
cmpq   $0x0,0x2e91(%rip)
jne    11d5 <pyobjc_internal_init+0xa5>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
jmp    11df <pyobjc_internal_init+0xaf>
jmp    11da <pyobjc_internal_init+0xaa>
jmp    11df <pyobjc_internal_init+0xaf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pyobjc_internal_init>:
push   %rbx
cmpq   $0x0,0x2f07(%rip)
jne    118c <pyobjc_internal_init+0x5c>
mov    0x2e9e(%rip),%rbx
mov    (%rbx),%esi
lea    0xee0(%rip),%rdi
call   1050 <dlopen@plt>
mov    %rax,0x2ee9(%rip)
test   %rax,%rax
jne    118c <pyobjc_internal_init+0x5c>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xe96(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    (%rbx),%esi
lea    0xea9(%rip),%rdi
call   1050 <dlopen@plt>
mov    %rax,0x2eb9(%rip)
test   %rax,%rax
je     118e <pyobjc_internal_init+0x5e>
pop    %rbx
ret
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xedb(%rip),%rdi
mov    %rax,%rsi
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@pyobjc_internal_init.foundation = internal global i8* null
@.str = [76 x i8] c"/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation\00"
@RTLD_LAZY = global i32 0
@.str.1 = [36 x i8] c"Got dlopen error on Foundation: %s\0A\00"
@.str.2 = [83 x i8] c"/Groups/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation\00"
@.str.3 = [45 x i8] c"Got fallback dlopen error on Foundation: %s\0A\00"
define void @pyobjc_internal_init() {
%1 = alloca i8*
%2 = load i8*, i8** @pyobjc_internal_init.foundation
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %23
4: ; preds = %0
%5 = load i32, i32* @RTLD_LAZY
%6 = call i8* @dlopen(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i32 %5)
store i8* %6, i8** @pyobjc_internal_init.foundation
%7 = load i8*, i8** @pyobjc_internal_init.foundation
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %22
9: ; preds = %4
%10 = call i8* (...) @dlerror()
store i8* %10, i8** %1
%11 = load i8*, i8** %1
%12 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @RTLD_LAZY
%14 = call i8* @dlopen(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.2, i64 0, i64 0), i32 %13)
store i8* %14, i8** @pyobjc_internal_init.foundation
%15 = load i8*, i8** @pyobjc_internal_init.foundation
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %21
17: ; preds = %9
%18 = call i8* (...) @dlerror()
store i8* %18, i8** %1
%19 = load i8*, i8** %1
%20 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* %19)
br label %23
21: ; preds = %9
br label %22
22: ; preds = %21, %4
br label %23
23: ; preds = %17, %22, %0
ret void
}

LLVM IR (-O2):
@pyobjc_internal_init.foundation = internal unnamed_addr global i8* null
@.str = [76 x i8] c"/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation\00"
@RTLD_LAZY = global i32 0
@.str.1 = [36 x i8] c"Got dlopen error on Foundation: %s\0A\00"
@.str.2 = [83 x i8] c"/Groups/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation\00"
@.str.3 = [45 x i8] c"Got fallback dlopen error on Foundation: %s\0A\00"
define void @pyobjc_internal_init() {
%1 = load i8*, i8** @pyobjc_internal_init.foundation
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %16
3: ; preds = %0
%4 = load i32, i32* @RTLD_LAZY
%5 = tail call i8* @dlopen(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i32 %4)
store i8* %5, i8** @pyobjc_internal_init.foundation
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %16
7: ; preds = %3
%8 = tail call i8* (...) @dlerror()
%9 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @RTLD_LAZY
%11 = tail call i8* @dlopen(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.2, i64 0, i64 0), i32 %10)
store i8* %11, i8** @pyobjc_internal_init.foundation
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = tail call i8* (...) @dlerror()
%15 = tail call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13, %7, %3, %0
ret void
}