#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 drmaa_exit(char *, int);
int /*<<< orphan*/ drmaa_get_DRMAA_implementation(char *, int, char *, int);
int /*<<< orphan*/ drmaa_get_DRM_system(char *, int, char *, int);
int /*<<< orphan*/ drmaa_get_contact(char *, int, char *, int);
int drmaa_init(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ drmaa_version(unsigned int *, unsigned int *, char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char error[1024];
  int result;
  char contact[1024];
  unsigned int major;
  unsigned int minor;
  char drm[1024];
  char impl[1024];
  result = drmaa_init(NULL, error, 1024 - 1);
  if (result != 0) {
    fprintf(stderr, "drmaa_init() failed: %s\n", error);
    return -1;
  } else
    printf("drmaa_init() success \n");
  drmaa_get_contact(contact, 1024 - 1, error, 1024 - 1);
  drmaa_version(&major, &minor, error, 1024 - 1);
  drmaa_get_DRM_system(drm, 1024 - 1, error, 1024 - 1);
  drmaa_get_DRMAA_implementation(impl, 1024 - 1, error, 1024 - 1);
  printf("Using %s, details:\n", impl);
  printf("\t DRMAA version %i.%i\n", major, minor);
  printf("\t DRMS %s (contact: %s)\n", drm, contact);
  result = drmaa_exit(error, 1024 - 1);
  if (result != 0) {
    fprintf(stderr, "drmaa_exit() failed: %s\n", error);
    return -1;
  } else
    printf("drmaa_exit() success \n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
mov    $0x3ff,%edx
call   1080 <drmaa_init@plt>
mov    %eax,-0x414(%rbp)
cmpl   $0x0,-0x414(%rbp)
je     11e9 <main+0x69>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rdx
lea    0xe28(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1310 <main+0x190>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x820(%rbp),%rdi
lea    -0x410(%rbp),%rdx
mov    $0x3ff,%ecx
mov    %ecx,%esi
call   1060 <drmaa_get_contact@plt>
lea    -0x410(%rbp),%rdx
lea    -0x824(%rbp),%rdi
lea    -0x828(%rbp),%rsi
mov    $0x3ff,%ecx
call   1090 <drmaa_version@plt>
lea    -0xc30(%rbp),%rdi
lea    -0x410(%rbp),%rdx
mov    $0x3ff,%ecx
mov    %ecx,%esi
call   1030 <drmaa_get_DRM_system@plt>
lea    -0x1030(%rbp),%rdi
lea    -0x410(%rbp),%rdx
mov    $0x3ff,%ecx
mov    %ecx,%esi
call   10a0 <drmaa_get_DRMAA_implementation@plt>
lea    -0x1030(%rbp),%rsi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x824(%rbp),%esi
mov    -0x828(%rbp),%edx
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xc30(%rbp),%rsi
lea    -0x820(%rbp),%rdx
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    $0x3ff,%esi
call   1040 <drmaa_exit@plt>
mov    %eax,-0x414(%rbp)
cmpl   $0x0,-0x414(%rbp)
je     12fb <main+0x17b>
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rdx
lea    0xd8a(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1310 <main+0x190>
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1010,%rsp
lea    0x10(%rsp),%rsi
xor    %edi,%edi
mov    $0x3ff,%edx
call   1090 <drmaa_init@plt>
test   %eax,%eax
je     11c9 <main+0x39>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
jmp    12a6 <main+0x116>
lea    0xea6(%rip),%rdi
call   1040 <puts@plt>
lea    0xc10(%rsp),%r14
lea    0x10(%rsp),%r12
mov    %r14,%rdi
mov    $0x3ff,%esi
mov    %r12,%rdx
mov    $0x3ff,%ecx
call   1070 <drmaa_get_contact@plt>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    %r12,%rdx
mov    $0x3ff,%ecx
call   10a0 <drmaa_version@plt>
lea    0x810(%rsp),%r15
mov    %r15,%rdi
mov    $0x3ff,%esi
mov    %r12,%rdx
mov    $0x3ff,%ecx
call   1030 <drmaa_get_DRM_system@plt>
lea    0x410(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3ff,%esi
mov    %r12,%rdx
mov    $0x3ff,%ecx
call   10b0 <drmaa_get_DRMAA_implementation@plt>
lea    0xdca(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0xdc3(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdcc(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
mov    $0x3ff,%esi
call   1050 <drmaa_exit@plt>
test   %eax,%eax
je     12c7 <main+0x137>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
lea    0xdb7(%rip),%rsi
lea    0x10(%rsp),%rdx
call   1080 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x1010,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdbe(%rip),%rdi
call   1040 <puts@plt>
jmp    12b5 <main+0x125>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"drmaa_init() failed: %s\0A\00"
@.str.1 = [23 x i8] c"drmaa_init() success \0A\00"
@.str.2 = [20 x i8] c"Using %s, details:\0A\00"
@.str.3 = [23 x i8] c"\09 DRMAA version %i.%i\0A\00"
@.str.4 = [25 x i8] c"\09 DRMS %s (contact: %s)\0A\00"
@.str.5 = [25 x i8] c"drmaa_exit() failed: %s\0A\00"
@.str.6 = [23 x i8] c"drmaa_exit() success \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca [1024 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca [1024 x i8]
%12 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%14 = call i32 @drmaa_init(i32* null, i8* %13, i32 1023)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %19)
store i32 -1, i32* %3
br label %54
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%26 = call i32 @drmaa_get_contact(i8* %24, i32 1023, i8* %25, i32 1023)
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%28 = call i32 @drmaa_version(i32* %9, i32* %10, i8* %27, i32 1023)
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%31 = call i32 @drmaa_get_DRM_system(i8* %29, i32 1023, i8* %30, i32 1023)
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%34 = call i32 @drmaa_get_DRMAA_implementation(i8* %32, i32 1023, i8* %33, i32 1023)
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = load i32, i32* %9
%38 = load i32, i32* %10
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %37, i32 %38)
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %40, i8* %41)
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%44 = call i32 @drmaa_exit(i8* %43, i32 1023)
store i32 %44, i32* %7
%45 = load i32, i32* %7
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %23
%48 = load i32, i32* @stderr
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%50 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %49)
store i32 -1, i32* %3
br label %54
51: ; preds = %23
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %53
53: ; preds = %51
store i32 0, i32* %3
br label %54
54: ; preds = %53, %47, %17
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"drmaa_init() failed: %s\0A\00"
@.str.2 = [20 x i8] c"Using %s, details:\0A\00"
@.str.3 = [23 x i8] c"\09 DRMAA version %i.%i\0A\00"
@.str.4 = [25 x i8] c"\09 DRMS %s (contact: %s)\0A\00"
@.str.5 = [25 x i8] c"drmaa_exit() failed: %s\0A\00"
@str = [22 x i8] c"drmaa_init() success \00"
@str.7 = [22 x i8] c"drmaa_exit() success \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%15 = call i32 @drmaa_init(i32* null, i8* %9, i32 1023)
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %38
20: ; preds = %2
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%22 = call i32 @drmaa_get_contact(i8* %10, i32 1023, i8* %9, i32 1023)
%23 = call i32 @drmaa_version(i32* %5, i32* %6, i8* %9, i32 1023)
%24 = call i32 @drmaa_get_DRM_system(i8* %13, i32 1023, i8* %9, i32 1023)
%25 = call i32 @drmaa_get_DRMAA_implementation(i8* %14, i32 1023, i8* %9, i32 1023)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %13, i8* %10)
%31 = call i32 @drmaa_exit(i8* %9, i32 1023)
%32 = icmp eq i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %20
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %9)
br label %38
36: ; preds = %20
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0))
br label %38
38: ; preds = %36, %33, %17
%39 = phi i32 [ -1, %17 ], [ -1, %33 ], [ 0, %36 ]
ret i32 %39
}