#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*/ strcpy(char *, char *);
int write_result(void *result_pointer, int number_columns, char **fields,
                 char **column_names) {
  int i;
  char(*result)[256] = (char(*)[256])result_pointer;
  for (i = 0; i != number_columns; i++) {
    if (fields[i] != NULL) {
      strcpy(result[i], fields[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<write_result>:
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,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1188 <write_result+0x78>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1175 <write_result+0x65>
mov    -0x30(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x8,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
jmp    117a <write_result+0x6a>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1136 <write_result+0x26>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_result>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     1153 <write_result+0x43>
mov    %rdx,%r14
mov    %rdi,%r12
mov    %esi,%r15d
xor    %ebx,%ebx
jmp    1140 <write_result+0x30>
nopl   0x0(%rax)
add    $0x1,%rbx
add    $0x100,%r12
cmp    %rbx,%r15
je     1153 <write_result+0x43>
mov    (%r14,%rbx,8),%rsi
test   %rsi,%rsi
je     1130 <write_result+0x20>
mov    %r12,%rdi
call   1030 <strcpy@plt>
jmp    1130 <write_result+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @write_result(i8* %0, i32 %1, i8** nocapture %2, i8** nocapture readnone %3) {
%5 = bitcast i8* %0 to [256 x i8]*
%6 = icmp eq i32 %1, 0
br i1 %6, label %20, label %7
7: ; preds = %4
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %17
%10 = phi i64 [ 0, %7 ], [ %18, %17 ]
%11 = getelementptr inbounds i8*, i8** %2, i64 %10
%12 = load i8*, i8** %11
%13 = icmp eq i8* %12, null
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 %10, i64 0
%16 = tail call i32 @strcpy(i8* %15, i8* %12)
br label %17
17: ; preds = %9, %14
%18 = add nuw nsw i64 %10, 1
%19 = icmp eq i64 %18, %8
br i1 %19, label %20, label %9
20: ; preds = %17, %4
ret i32 0
}