#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 */
scalar_t__ lt_malloc(int);
long safe_strtol(char const *, char const **, int);
int /*<<< orphan*/ snprintf(char *, int, char *, long, long, long);
char const *darwin_dynamic_link_function(char const *version_info) {
  char *newarg;
  long major, minor, patch;
  major = 0;
  minor = 0;
  patch = 0;
  if (version_info) {
    major = safe_strtol(version_info, &version_info, 10);
    if (version_info) {
      if (version_info[0] == ':') {
        version_info++;
      }
      minor = safe_strtol(version_info, &version_info, 10);
      if (version_info) {
        if (version_info[0] == ':') {
          version_info++;
        }
        patch = safe_strtol(version_info, &version_info, 10);
      }
    }
  }
  if (major == 0) {
    major = 1;
  }
  newarg = (char *)lt_malloc(100);
  snprintf(newarg, 99, "-compatibility_version %ld -current_version %ld.%ld",
           major, major, minor);
  return newarg;
}


x86 assembly (clang, -O0):
<darwin_dynamic_link_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11f9 <darwin_dynamic_link_function+0xc9>
mov    -0x8(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0xa,%edx
call   1030 <safe_strtol@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11f4 <darwin_dynamic_link_function+0xc4>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    119c <darwin_dynamic_link_function+0x6c>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0xa,%edx
call   1030 <safe_strtol@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11ef <darwin_dynamic_link_function+0xbf>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    11d9 <darwin_dynamic_link_function+0xa9>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0xa,%edx
call   1030 <safe_strtol@plt>
mov    %rax,-0x28(%rbp)
jmp    11f4 <darwin_dynamic_link_function+0xc4>
jmp    11f9 <darwin_dynamic_link_function+0xc9>
cmpq   $0x0,-0x18(%rbp)
jne    120c <darwin_dynamic_link_function+0xdc>
movq   $0x1,-0x18(%rbp)
mov    $0x64,%edi
call   1050 <lt_malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    $0x63,%esi
lea    0xdca(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<darwin_dynamic_link_function>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,0x8(%rsp)
test   %rdi,%rdi
je     11ad <darwin_dynamic_link_function+0x7d>
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1030 <safe_strtol@plt>
mov    %rax,%r15
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     11b8 <darwin_dynamic_link_function+0x88>
cmpb   $0x3a,(%rdi)
jne    116d <darwin_dynamic_link_function+0x3d>
add    $0x1,%rdi
mov    %rdi,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1030 <safe_strtol@plt>
mov    %rax,%r14
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     11a6 <darwin_dynamic_link_function+0x76>
cmpb   $0x3a,(%rdi)
jne    1197 <darwin_dynamic_link_function+0x67>
add    $0x1,%rdi
mov    %rdi,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1030 <safe_strtol@plt>
test   %r15,%r15
jne    11c0 <darwin_dynamic_link_function+0x90>
jmp    11b0 <darwin_dynamic_link_function+0x80>
xor    %r14d,%r14d
mov    $0x1,%r15d
jmp    11c0 <darwin_dynamic_link_function+0x90>
xor    %r14d,%r14d
test   %r15,%r15
je     11b0 <darwin_dynamic_link_function+0x80>
mov    $0x64,%edi
call   1050 <lt_malloc@plt>
mov    %rax,%rbx
lea    0xe2c(%rip),%rdx
mov    %rax,%rdi
mov    $0x63,%esi
mov    %r15,%rcx
mov    %r15,%r8
mov    %r14,%r9
call   1040 <snprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [52 x i8] c"-compatibility_version %ld -current_version %ld.%ld\00"
define i8* @darwin_dynamic_link_function(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %2
store i64 0, i64* %4
store i64 0, i64* %5
store i64 0, i64* %6
%7 = load i8*, i8** %2
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %42
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i64 @safe_strtol(i8* %10, i8** %2, i32 10)
store i64 %11, i64* %4
%12 = load i8*, i8** %2
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %41
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 58
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %2
br label %23
23: ; preds = %20, %14
%24 = load i8*, i8** %2
%25 = call i64 @safe_strtol(i8* %24, i8** %2, i32 10)
store i64 %25, i64* %5
%26 = load i8*, i8** %2
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %40
28: ; preds = %23
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 58
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i8*, i8** %2
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %2
br label %37
37: ; preds = %34, %28
%38 = load i8*, i8** %2
%39 = call i64 @safe_strtol(i8* %38, i8** %2, i32 10)
store i64 %39, i64* %6
br label %40
40: ; preds = %37, %23
br label %41
41: ; preds = %40, %9
br label %42
42: ; preds = %41, %1
%43 = load i64, i64* %4
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %42
store i64 1, i64* %4
br label %46
46: ; preds = %45, %42
%47 = call i64 @lt_malloc(i32 100)
%48 = inttoptr i64 %47 to i8*
store i8* %48, i8** %3
%49 = load i8*, i8** %3
%50 = load i64, i64* %4
%51 = load i64, i64* %4
%52 = load i64, i64* %5
%53 = call i32 @snprintf(i8* %49, i32 99, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i64 %50, i64 %51, i64 %52)
%54 = load i8*, i8** %3
ret i8* %54
}

LLVM IR (-O2):
@.str = [52 x i8] c"-compatibility_version %ld -current_version %ld.%ld\00"
define i8* @darwin_dynamic_link_function(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = icmp eq i8* %0, null
br i1 %3, label %29, label %4
4: ; preds = %1
%5 = call i64 @safe_strtol(i8* %0, i8** %2, i32 10)
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
br i1 %7, label %26, label %8
8: ; preds = %4
%9 = load i8, i8* %6
%10 = icmp eq i8 %9, 58
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %12, i8** %2
br label %13
13: ; preds = %11, %8
%14 = phi i8* [ %12, %11 ], [ %6, %8 ]
%15 = call i64 @safe_strtol(i8* %14, i8** %2, i32 10)
%16 = load i8*, i8** %2
%17 = icmp eq i8* %16, null
br i1 %17, label %26, label %18
18: ; preds = %13
%19 = load i8, i8* %16
%20 = icmp eq i8 %19, 58
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = getelementptr inbounds i8, i8* %16, i64 1
store i8* %22, i8** %2
br label %23
23: ; preds = %21, %18
%24 = phi i8* [ %22, %21 ], [ %16, %18 ]
%25 = call i64 @safe_strtol(i8* %24, i8** %2, i32 10)
br label %26
26: ; preds = %4, %23, %13
%27 = phi i64 [ %15, %23 ], [ %15, %13 ], [ 0, %4 ]
%28 = icmp eq i64 %5, 0
br i1 %28, label %29, label %31
29: ; preds = %1, %26
%30 = phi i64 [ %27, %26 ], [ 0, %1 ]
br label %31
31: ; preds = %26, %29
%32 = phi i64 [ %30, %29 ], [ %27, %26 ]
%33 = phi i64 [ 1, %29 ], [ %5, %26 ]
%34 = call i64 @lt_malloc(i32 100)
%35 = inttoptr i64 %34 to i8*
%36 = call i32 @snprintf(i8* %35, i32 99, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i64 %33, i64 %33, i64 %32)
ret i8* %35
}