#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 *expand_argument(char const *, char const *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strip_whitespace(char const **, char const **);
int strlen(char *);
char *variable_buffer_output(char *, char *, int);
char *func_or(char *o, char **argv,
              const char *funcname __attribute__((unused))) {
  for (; *argv; ++argv) {
    const char *begp = *argv;
    const char *endp = begp + strlen(*argv) - 1;
    char *expansion;
    int result = 0;
    strip_whitespace(&begp, &endp);
    if (begp > endp)
      continue;
    expansion = expand_argument(begp, endp + 1);
    result = strlen(expansion);
    if (!result) {
      free(expansion);
      continue;
    }
    o = variable_buffer_output(o, expansion, result);
    free(expansion);
    break;
  }
  return o;
}


x86 assembly (clang, -O0):
<func_or>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1238 <func_or+0xe8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <strip_whitespace@plt>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jbe    11cc <func_or+0x7c>
jmp    1227 <func_or+0xd7>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
call   1070 <expand_argument@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    1205 <func_or+0xb5>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    1227 <func_or+0xd7>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1060 <variable_buffer_output@plt>
mov    %rax,-0x8(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    1238 <func_or+0xe8>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1164 <func_or+0x14>
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func_or>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    (%rsi),%rbx
test   %rbx,%rbx
je     11fa <func_or+0xaa>
mov    %rsi,%r13
add    $0x8,%r13
lea    0x8(%rsp),%r15
mov    %rsp,%r12
jmp    118d <func_or+0x3d>
nopl   (%rax)
mov    0x0(%r13),%rbx
add    $0x8,%r13
test   %rbx,%rbx
je     11fa <func_or+0xaa>
mov    %rbx,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <strip_whitespace@plt>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
cmp    %rsi,%rdi
ja     1180 <func_or+0x30>
add    $0x1,%rsi
call   1070 <expand_argument@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jne    11e2 <func_or+0x92>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1180 <func_or+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <variable_buffer_output@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @func_or(i8* %0, i8** %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8* %2, i8** %6
br label %11
11: ; preds = %49, %3
%12 = load i8**, i8*** %5
%13 = load i8*, i8** %12
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %52
15: ; preds = %11
%16 = load i8**, i8*** %5
%17 = load i8*, i8** %16
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = load i8**, i8*** %5
%20 = load i8*, i8** %19
%21 = call i32 @strlen(i8* %20)
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %18, i64 %22
%24 = getelementptr inbounds i8, i8* %23, i64 -1
store i8* %24, i8** %8
store i32 0, i32* %10
%25 = call i32 @strip_whitespace(i8** %7, i8** %8)
%26 = load i8*, i8** %7
%27 = load i8*, i8** %8
%28 = icmp ugt i8* %26, %27
br i1 %28, label %29, label %30
29: ; preds = %15
br label %49
30: ; preds = %15
%31 = load i8*, i8** %7
%32 = load i8*, i8** %8
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = call i8* @expand_argument(i8* %31, i8* %33)
store i8* %34, i8** %9
%35 = load i8*, i8** %9
%36 = call i32 @strlen(i8* %35)
store i32 %36, i32* %10
%37 = load i32, i32* %10
%38 = icmp ne i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %30
%40 = load i8*, i8** %9
%41 = call i32 @free(i8* %40)
br label %49
42: ; preds = %30
%43 = load i8*, i8** %4
%44 = load i8*, i8** %9
%45 = load i32, i32* %10
%46 = call i8* @variable_buffer_output(i8* %43, i8* %44, i32 %45)
store i8* %46, i8** %4
%47 = load i8*, i8** %9
%48 = call i32 @free(i8* %47)
br label %52
49: ; preds = %39, %29
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i32 1
store i8** %51, i8*** %5
br label %11
52: ; preds = %42, %11
%53 = load i8*, i8** %4
ret i8* %53
}

LLVM IR (-O2):
define i8* @func_or(i8* %0, i8** nocapture %1, i8* nocapture readnone %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = load i8*, i8** %1
%7 = icmp eq i8* %6, null
br i1 %7, label %36, label %8
8: ; preds = %3
%9 = bitcast i8** %4 to i8*
%10 = bitcast i8** %5 to i8*
br label %11
11: ; preds = %8, %32
%12 = phi i8* [ %6, %8 ], [ %34, %32 ]
%13 = phi i8** [ %1, %8 ], [ %33, %32 ]
store i8* %12, i8** %4
%14 = call i32 @strlen(i8* %12)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 -1
%17 = getelementptr inbounds i8, i8* %16, i64 %15
store i8* %17, i8** %5
%18 = call i32 @strip_whitespace(i8** %4, i8** %5)
%19 = load i8*, i8** %4
%20 = load i8*, i8** %5
%21 = icmp ugt i8* %19, %20
br i1 %21, label %32, label %22
22: ; preds = %11
%23 = getelementptr inbounds i8, i8* %20, i64 1
%24 = call i8* @expand_argument(i8* %19, i8* %23)
%25 = call i32 @strlen(i8* %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = call i32 @free(i8* %24)
br label %32
29: ; preds = %22
%30 = call i8* @variable_buffer_output(i8* %0, i8* %24, i32 %25)
%31 = call i32 @free(i8* %24)
br label %36
32: ; preds = %27, %11
%33 = getelementptr inbounds i8*, i8** %13, i64 1
%34 = load i8*, i8** %33
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %11
36: ; preds = %32, %3, %29
%37 = phi i8* [ %30, %29 ], [ %0, %3 ], [ %0, %32 ]
ret i8* %37
}