#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 EXIT_SUCCESS;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main(int argc, char **argv) {
  int i = 1, newline = 1, first = 1;
  ;
  if (argc > 1) {
    if (strcmp("-n", argv[1]) == 0) {
      i++;
      newline = 0;
    } else if (strcmp("--help", argv[1]) == 0) {
      printf("echo: [-n|--help] STRING...\n");
      return EXIT_SUCCESS;
    }
  }
  for (; i < argc; i++) {
    if (!first)
      write(STDOUT_FILENO, " ", 1);
    first = 0;
    write(STDOUT_FILENO, argv[i], strlen(argv[i]));
  }
  if (newline)
    write(STDOUT_FILENO, "\n", 1);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11ed <main+0xad>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe7c(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11a8 <main+0x68>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    11e8 <main+0xa8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe4c(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11e3 <main+0xa3>
lea    0xe3d(%rip),%rdi
call   1050 <printf@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a2 <main+0x162>
jmp    11e8 <main+0xa8>
jmp    11ed <main+0xad>
jmp    11f2 <main+0xb2>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1272 <main+0x132>
cmpl   $0x0,-0x1c(%rbp)
jne    1222 <main+0xe2>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
lea    0xe0f(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
movl   $0x0,-0x1c(%rbp)
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f2 <main+0xb2>
cmpl   $0x0,-0x18(%rbp)
je     1296 <main+0x156>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
lea    0xd99(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    0x2d3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebx
mov    $0x1,%ebp
cmp    $0x2,%edi
jl     1188 <main+0x48>
mov    0x8(%r15),%rsi
lea    0xe9b(%rip),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1199 <main+0x59>
mov    0x8(%r15),%rsi
lea    0xe89(%rip),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     123c <main+0xfc>
movl   $0x0,0x4(%rsp)
cmp    %ebx,%ebp
jl     11a8 <main+0x68>
jmp    1219 <main+0xd9>
mov    $0x1,%al
mov    %eax,0x4(%rsp)
mov    $0x2,%ebp
cmp    %ebx,%ebp
jge    1219 <main+0xd9>
mov    %ebp,%ebp
mov    %ebx,%r12d
mov    0x2e3c(%rip),%r14
mov    (%r14),%r13d
mov    (%r15,%rbp,8),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
add    $0x1,%rbp
cmp    %r12,%rbp
je     1219 <main+0xd9>
nopl   0x0(%rax)
mov    (%r14),%edi
lea    0xe20(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    (%r14),%r13d
mov    (%r15,%rbp,8),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11e0 <main+0xa0>
cmpb   $0x0,0x4(%rsp)
jne    1248 <main+0x108>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
jmp    1248 <main+0x108>
lea    0xdcb(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d89(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"-n\00"
@.str.1 = [7 x i8] c"--help\00"
@EXIT_SUCCESS = global i32 0
@STDOUT_FILENO = global i32 0
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c"\0A\00"
@str = [28 x i8] c"echo: [-n|--help] STRING...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %15
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %4
%10 = load i8*, i8** %5
%11 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %44
15: ; preds = %4, %9, %2
%16 = phi i32 [ 1, %9 ], [ 1, %2 ], [ 2, %4 ]
%17 = phi i1 [ false, %9 ], [ false, %2 ], [ true, %4 ]
%18 = icmp slt i32 %16, %0
br i1 %18, label %19, label %40
19: ; preds = %15
%20 = zext i32 %16 to i64
%21 = zext i32 %0 to i64
%22 = load i32, i32* @STDOUT_FILENO
%23 = getelementptr inbounds i8*, i8** %1, i64 %20
%24 = load i8*, i8** %23
%25 = tail call i32 @strlen(i8* %24)
%26 = tail call i32 @write(i32 %22, i8* %24, i32 %25)
%27 = add nuw nsw i64 %20, 1
%28 = icmp eq i64 %27, %21
br i1 %28, label %40, label %29
29: ; preds = %19, %29
%30 = phi i64 [ %38, %29 ], [ %27, %19 ]
%31 = load i32, i32* @STDOUT_FILENO
%32 = tail call i32 @write(i32 %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%33 = load i32, i32* @STDOUT_FILENO
%34 = getelementptr inbounds i8*, i8** %1, i64 %30
%35 = load i8*, i8** %34
%36 = tail call i32 @strlen(i8* %35)
%37 = tail call i32 @write(i32 %33, i8* %35, i32 %36)
%38 = add nuw nsw i64 %30, 1
%39 = icmp eq i64 %38, %21
br i1 %39, label %40, label %29
40: ; preds = %29, %19, %15
br i1 %17, label %44, label %41
41: ; preds = %40
%42 = load i32, i32* @STDOUT_FILENO
%43 = tail call i32 @write(i32 %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
br label %44
44: ; preds = %40, %41, %13
%45 = load i32, i32* @EXIT_SUCCESS
ret i32 %45
}