#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*/ assert(int /*<<< orphan*/);
char *malloc(size_t);
int /*<<< orphan*/ sprintf(char *, char const *, char *, char *, char *);
size_t strlen(char const *);
char *sprintfGitInfo(char **buffer) {
  if (!buffer)
    return NULL;
  if (*buffer)
    assert(0);
  const char *format = "git tag: %s\ngit branch: %s\nHEAD @: %s";
  size_t length = strlen(format) + strlen("UNKNOWN") + strlen("UNKNOWN") +
                  strlen("UNKNOWN");
  *buffer = malloc(length * sizeof(char));
  if (!*buffer)
    return NULL;
  sprintf(*buffer, format, "UNKNOWN", "UNKNOWN", "UNKNOWN");
  return *buffer;
}


x86 assembly (clang, -O0):
<sprintfGitInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1164 <sprintfGitInfo+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11f7 <sprintfGitInfo+0xb7>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1179 <sprintfGitInfo+0x39>
xor    %edi,%edi
call   1040 <assert@plt>
lea    0xe80(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x7,%rax
add    $0x7,%rax
add    $0x7,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
shl    $0x0,%rdi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11cf <sprintfGitInfo+0x8f>
movq   $0x0,-0x8(%rbp)
jmp    11f7 <sprintfGitInfo+0xb7>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
lea    0xe45(%rip),%r8
mov    %r8,%rdx
mov    %r8,%rcx
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sprintfGitInfo>:
push   %rbx
test   %rdi,%rdi
je     1179 <sprintfGitInfo+0x49>
mov    %rdi,%rbx
cmpq   $0x0,(%rdi)
je     1146 <sprintfGitInfo+0x16>
xor    %edi,%edi
call   1030 <assert@plt>
mov    $0x3a,%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     1179 <sprintfGitInfo+0x49>
lea    0xea1(%rip),%rsi
lea    0xec0(%rip),%rcx
mov    %rax,%rdi
mov    %rcx,%rdx
mov    %rcx,%r8
call   1050 <sprintf@plt>
mov    (%rbx),%rax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"git tag: %s\0Agit branch: %s\0AHEAD @: %s\00"
@.str.1 = [8 x i8] c"UNKNOWN\00"
define i8* @sprintfGitInfo(i8** %0) {
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i64
store i8** %0, i8*** %3
%6 = load i8**, i8*** %3
%7 = icmp ne i8** %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i8* null, i8** %2
br label %36
9: ; preds = %1
%10 = load i8**, i8*** %3
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @assert(i32 0)
br label %15
15: ; preds = %13, %9
store i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8** %4
%16 = load i8*, i8** %4
%17 = call i64 @strlen(i8* %16)
%18 = add i64 %17, 7
%19 = add i64 %18, 7
%20 = add i64 %19, 7
store i64 %20, i64* %5
%21 = load i64, i64* %5
%22 = mul i64 %21, 1
%23 = call i8* @malloc(i64 %22)
%24 = load i8**, i8*** %3
store i8* %23, i8** %24
%25 = load i8**, i8*** %3
%26 = load i8*, i8** %25
%27 = icmp ne i8* %26, null
br i1 %27, label %29, label %28
28: ; preds = %15
store i8* null, i8** %2
br label %36
29: ; preds = %15
%30 = load i8**, i8*** %3
%31 = load i8*, i8** %30
%32 = load i8*, i8** %4
%33 = call i32 @sprintf(i8* %31, i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%34 = load i8**, i8*** %3
%35 = load i8*, i8** %34
store i8* %35, i8** %2
br label %36
36: ; preds = %29, %28, %8
%37 = load i8*, i8** %2
ret i8* %37
}

LLVM IR (-O2):
@.str = [38 x i8] c"git tag: %s\0Agit branch: %s\0AHEAD @: %s\00"
@.str.1 = [8 x i8] c"UNKNOWN\00"
define i8* @sprintfGitInfo(i8** %0) {
%2 = icmp eq i8** %0, null
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = load i8*, i8** %0
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @assert(i32 0)
br label %8
8: ; preds = %6, %3
%9 = tail call dereferenceable_or_null(58) i8* @malloc(i64 58)
store i8* %9, i8** %0
%10 = icmp eq i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%13 = load i8*, i8** %0
br label %14
14: ; preds = %11, %8, %1
%15 = phi i8* [ null, %1 ], [ %13, %11 ], [ null, %8 ]
ret i8* %15
}