#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 */
char *get_field_string_from_identifier(int, int, char *, char *);
int /*<<< orphan*/ to_lower(char *);
char *get_field(int identifier, int no_of_fields, char *fieldname,
                char *value) {
  char *result = get_field_string_from_identifier(identifier, no_of_fields,
                                                  fieldname, value);
  if (result == 0) {
    identifier++;
    result = get_field_string_from_identifier(identifier, no_of_fields,
                                              fieldname, value);
  }
  to_lower(result);
  return result;
}


x86 assembly (clang, -O0):
<get_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1040 <get_field_string_from_identifier@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1178 <get_field+0x58>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1040 <get_field_string_from_identifier@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <to_lower@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_field>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%r12d
mov    %edi,%ebx
call   1040 <get_field_string_from_identifier@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1156 <get_field+0x36>
add    $0x1,%ebx
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <get_field_string_from_identifier@plt>
mov    %rax,%rbp
mov    %rbp,%rdi
call   1030 <to_lower@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @get_field(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = load i8*, i8** %7
%13 = load i8*, i8** %8
%14 = call i8* @get_field_string_from_identifier(i32 %10, i32 %11, i8* %12, i8* %13)
store i8* %14, i8** %9
%15 = load i8*, i8** %9
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %25
17: ; preds = %4
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = load i8*, i8** %7
%23 = load i8*, i8** %8
%24 = call i8* @get_field_string_from_identifier(i32 %20, i32 %21, i8* %22, i8* %23)
store i8* %24, i8** %9
br label %25
25: ; preds = %17, %4
%26 = load i8*, i8** %9
%27 = call i32 @to_lower(i8* %26)
%28 = load i8*, i8** %9
ret i8* %28
}

LLVM IR (-O2):
define i8* @get_field(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = tail call i8* @get_field_string_from_identifier(i32 %0, i32 %1, i8* %2, i8* %3)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = add nsw i32 %0, 1
%9 = tail call i8* @get_field_string_from_identifier(i32 %8, i32 %1, i8* %2, i8* %3)
br label %10
10: ; preds = %7, %4
%11 = phi i8* [ %9, %7 ], [ %5, %4 ]
%12 = tail call i32 @to_lower(i8* %11)
ret i8* %11
}