#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 *search_for_value(char **, char *);
int strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[], char *envp[]) {
  if (argc == 1) {
    return 0;
  }
  if (argc >= 2) {
    char *argument = argv[1];
    if (argument[0] == '$') {
      char *value = search_for_value(envp, argument + 1);
      write(1, value, strlen(value));
      write(1, "\n", 1);
    } else {
      int i = 1;
      while (i < argc) {
        write(1, argv[i], strlen(argv[i]));
        i++;
      }
      write(1, "\n", 1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1160 <main+0x30>
movl   $0x0,-0x4(%rbp)
jmp    1245 <main+0x115>
cmpl   $0x2,-0x8(%rbp)
jl     123e <main+0x10e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    11d4 <main+0xa4>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1050 <search_for_value@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe38(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
jmp    1239 <main+0x109>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1226 <main+0xf6>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11db <main+0xab>
mov    $0x1,%edx
lea    0xdce(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
jmp    123e <main+0x10e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x2,%edi
jl     11e4 <main+0xb4>
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    0x8(%rsi),%rbp
cmpb   $0x24,0x0(%rbp)
jne    1178 <main+0x48>
add    $0x1,%rbp
mov    %rdx,%rdi
mov    %rbp,%rsi
call   1050 <search_for_value@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
jmp    11c4 <main+0x94>
mov    %edi,%r14d
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0x2,%r14d
je     11c4 <main+0x94>
mov    %r14d,%r14d
mov    $0x2,%ebx
mov    (%r15,%rbx,8),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11a0 <main+0x70>
lea    0xe35(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 0, i32* %4
br label %60
14: ; preds = %3
%15 = load i32, i32* %5
%16 = icmp sge i32 %15, 2
br i1 %16, label %17, label %59
17: ; preds = %14
%18 = load i8**, i8*** %6
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %8
%21 = load i8*, i8** %8
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 36
br i1 %25, label %26, label %36
26: ; preds = %17
%27 = load i8**, i8*** %7
%28 = load i8*, i8** %8
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = call i8* @search_for_value(i8** %27, i8* %29)
store i8* %30, i8** %9
%31 = load i8*, i8** %9
%32 = load i8*, i8** %9
%33 = call i32 @strlen(i8* %32)
%34 = call i32 @write(i32 1, i8* %31, i32 %33)
%35 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %58
36: ; preds = %17
store i32 1, i32* %10
br label %37
37: ; preds = %41, %36
%38 = load i32, i32* %10
%39 = load i32, i32* %5
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %56
41: ; preds = %37
%42 = load i8**, i8*** %6
%43 = load i32, i32* %10
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = load i8**, i8*** %6
%48 = load i32, i32* %10
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = call i32 @strlen(i8* %51)
%53 = call i32 @write(i32 1, i8* %46, i32 %52)
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %37
56: ; preds = %37
%57 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %58
58: ; preds = %56, %26
br label %59
59: ; preds = %58, %14
store i32 0, i32* %4
br label %60
60: ; preds = %59, %13
%61 = load i32, i32* %4
ret i32 %61
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** %2) {
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %30
5: ; preds = %3
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 36
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = zext i32 %0 to i64
%12 = tail call i32 @strlen(i8* %7)
%13 = tail call i32 @write(i32 1, i8* %7, i32 %12)
%14 = icmp eq i32 %0, 2
br i1 %14, label %28, label %20
15: ; preds = %5
%16 = getelementptr inbounds i8, i8* %7, i64 1
%17 = tail call i8* @search_for_value(i8** %2, i8* %16)
%18 = tail call i32 @strlen(i8* %17)
%19 = tail call i32 @write(i32 1, i8* %17, i32 %18)
br label %28
20: ; preds = %10, %20
%21 = phi i64 [ %26, %20 ], [ 2, %10 ]
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
%24 = tail call i32 @strlen(i8* %23)
%25 = tail call i32 @write(i32 1, i8* %23, i32 %24)
%26 = add nuw nsw i64 %21, 1
%27 = icmp eq i64 %26, %11
br i1 %27, label %28, label %20
28: ; preds = %20, %10, %15
%29 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %30
30: ; preds = %28, %3
ret i32 0
}