#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 */
struct cosmos {
  int dummy;
};

/* Variables and functions */
struct cosmos *cosmos_init(int, char **);
struct cosmos *db_init() {
  struct cosmos *cm;
  int modc = 6;
  char *mod_path[] = {
      "/usr/lib/cosmos",
      "/usr/lib/cosmos/svc/file.so",
      "/usr/lib/cosmos/svc/dylib.so",
      "/usr/lib/cosmos/svc/ptr.so",
      "/usr/lib/cosmos/xformr/dcelcosm.so",
      "/usr/lib/cosmos/lookup/fudge.so",
  };
  cm = cosmos_init(modc, mod_path);
}


x86 assembly (clang, -O0):
<db_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x6,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
lea    0xeba(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xebf(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xed0(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xee2(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xef2(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xf0a(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x50(%rbp),%rsi
call   1030 <cosmos_init@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_init>:
sub    $0x38,%rsp
lea    0xee5(%rip),%rax
mov    %rax,(%rsp)
lea    0xeea(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xefa(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xf0b(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xf1a(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xf31(%rip),%rax
mov    %rax,0x28(%rsp)
mov    %rsp,%rsi
mov    $0x6,%edi
call   1030 <cosmos_init@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
%struct.cosmos = type { i32 }
@.str = [16 x i8] c"/usr/lib/cosmos\00"
@.str.1 = [28 x i8] c"/usr/lib/cosmos/svc/file.so\00"
@.str.2 = [29 x i8] c"/usr/lib/cosmos/svc/dylib.so\00"
@.str.3 = [27 x i8] c"/usr/lib/cosmos/svc/ptr.so\00"
@.str.4 = [35 x i8] c"/usr/lib/cosmos/xformr/dcelcosm.so\00"
@.str.5 = [32 x i8] c"/usr/lib/cosmos/lookup/fudge.so\00"
define %struct.cosmos* @db_init() {
%1 = alloca %struct.cosmos*
%2 = alloca %struct.cosmos*
%3 = alloca i32
%4 = alloca [6 x i8*]
store i32 6, i32* %3
%5 = bitcast [6 x i8*]* %4 to i8*
%6 = bitcast i8* %5 to [6 x i8*]*
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 0
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i32 0, i32 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 1
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 2
store i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 3
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 4
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 5
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i32 0, i32 0), i8** %12
%13 = load i32, i32* %3
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 0
%15 = call %struct.cosmos* @cosmos_init(i32 %13, i8** %14)
store %struct.cosmos* %15, %struct.cosmos** %2
%16 = load %struct.cosmos*, %struct.cosmos** %1
ret %struct.cosmos* %16
}

LLVM IR (-O2):
%struct.cosmos = type { i32 }
@.str = [16 x i8] c"/usr/lib/cosmos\00"
@.str.1 = [28 x i8] c"/usr/lib/cosmos/svc/file.so\00"
@.str.2 = [29 x i8] c"/usr/lib/cosmos/svc/dylib.so\00"
@.str.3 = [27 x i8] c"/usr/lib/cosmos/svc/ptr.so\00"
@.str.4 = [35 x i8] c"/usr/lib/cosmos/xformr/dcelcosm.so\00"
@.str.5 = [32 x i8] c"/usr/lib/cosmos/lookup/fudge.so\00"
define noalias %struct.cosmos* @db_init() {
%1 = alloca [6 x i8*]
%2 = bitcast [6 x i8*]* %1 to i8*
%3 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 2
store i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 3
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 4
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 5
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8** %8
%9 = call %struct.cosmos* @cosmos_init(i32 6, i8** %3)
ret %struct.cosmos* undef
}