#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*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int status_version(void *ptr, int field_count, char **row, char **fields) {
  char *str = ptr;
  (void)fields;
  str[0] = '\0';
  if (row[0]) {
    strcpy(str, row[0]);
  } else {
    str[0] = '0';
    str[1] = '\0';
  }
  if (field_count > 1) {
    if (row[1]) {
      strcat(str, row[1]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<status_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1169 <status_version+0x49>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
jmp    1178 <status_version+0x58>
mov    -0x28(%rbp),%rax
movb   $0x30,(%rax)
mov    -0x28(%rbp),%rax
movb   $0x0,0x1(%rax)
cmpl   $0x1,-0xc(%rbp)
jle    11a7 <status_version+0x87>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11a2 <status_version+0x82>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcat@plt>
jmp    11a7 <status_version+0x87>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<status_version>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
movb   $0x0,(%rdi)
mov    (%rdx),%rsi
test   %rsi,%rsi
je     1146 <status_version+0x26>
mov    %rbx,%rdi
call   1030 <strcpy@plt>
cmp    $0x2,%ebp
jge    1150 <status_version+0x30>
jmp    1161 <status_version+0x41>
movw   $0x30,(%rbx)
cmp    $0x2,%ebp
jl     1161 <status_version+0x41>
mov    0x8(%r14),%rsi
test   %rsi,%rsi
je     1161 <status_version+0x41>
mov    %rbx,%rdi
call   1040 <strcat@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @status_version(i8* %0, i32 %1, i8** %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i8** %3, i8*** %8
%10 = load i8*, i8** %5
store i8* %10, i8** %9
%11 = load i8**, i8*** %8
%12 = load i8*, i8** %9
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 0, i8* %13
%14 = load i8**, i8*** %7
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %24
18: ; preds = %4
%19 = load i8*, i8** %9
%20 = load i8**, i8*** %7
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @strcpy(i8* %19, i8* %22)
br label %29
24: ; preds = %4
%25 = load i8*, i8** %9
%26 = getelementptr inbounds i8, i8* %25, i64 0
store i8 48, i8* %26
%27 = load i8*, i8** %9
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8 0, i8* %28
br label %29
29: ; preds = %24, %18
%30 = load i32, i32* %6
%31 = icmp sgt i32 %30, 1
br i1 %31, label %32, label %44
32: ; preds = %29
%33 = load i8**, i8*** %7
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %43
37: ; preds = %32
%38 = load i8*, i8** %9
%39 = load i8**, i8*** %7
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 @strcat(i8* %38, i8* %41)
br label %43
43: ; preds = %37, %32
br label %44
44: ; preds = %43, %29
ret i32 0
}

LLVM IR (-O2):
define i32 @status_version(i8* %0, i32 %1, i8** nocapture %2, i8** nocapture readnone %3) {
store i8 0, i8* %0
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @strcpy(i8* %0, i8* %5)
br label %11
9: ; preds = %4
store i8 48, i8* %0
%10 = getelementptr inbounds i8, i8* %0, i64 1
store i8 0, i8* %10
br label %11
11: ; preds = %9, %7
%12 = icmp sgt i32 %1, 1
br i1 %12, label %13, label %19
13: ; preds = %11
%14 = getelementptr inbounds i8*, i8** %2, i64 1
%15 = load i8*, i8** %14
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = tail call i32 @strcat(i8* %0, i8* %15)
br label %19
19: ; preds = %13, %17, %11
ret i32 0
}