#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
scalar_t__ xstrcmp(char *, char *);
int sd_echo(int argc, char **argv, int in, int out, int err) {
  int nflag;
  int i;
  (void)in;
  (void)out;
  (void)err;
  if (argc < 1)
    return 0;
  if (xstrcmp(argv[0], "-n") == 0) {
    nflag = 1;
  } else {
    nflag = 0;
  }
  for (i = nflag ? 1 : 0; i < argc; i++) {
    fprintf(stdout, "%s", argv[i]);
    if (i < argc - 1)
      fprintf(stdout, " ");
  }
  if (!nflag)
    fprintf(stdout, "\n");
  else
    fflush(stdout);
  return 0;
}


x86 assembly (clang, -O0):
<sd_echo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    115f <sd_echo+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    1247 <sd_echo+0x117>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe93(%rip),%rsi
call   1040 <xstrcmp@plt>
cmp    $0x0,%rax
jne    1188 <sd_echo+0x58>
movl   $0x1,-0x20(%rbp)
jmp    118f <sd_echo+0x5f>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120c <sd_echo+0xdc>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11f9 <sd_echo+0xc9>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11fe <sd_echo+0xce>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a2 <sd_echo+0x72>
cmpl   $0x0,-0x20(%rbp)
jne    1232 <sd_echo+0x102>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
lea    0xde2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1240 <sd_echo+0x110>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sd_echo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11ea <sd_echo+0xba>
mov    %rsi,%r13
mov    %edi,%r15d
mov    (%rsi),%rdi
lea    0xead(%rip),%rsi
call   1040 <xstrcmp@plt>
xor    %ecx,%ecx
mov    %rax,(%rsp)
test   %rax,%rax
sete   %cl
cmp    %r15d,%ecx
jae    11c5 <sd_echo+0x95>
xor    %ebx,%ebx
cmpq   $0x0,(%rsp)
sete   %bl
lea    -0x1(%r15),%ebp
mov    %r15d,%r14d
mov    0x2e5f(%rip),%r12
lea    0xe7b(%rip),%r15
jmp    1199 <sd_echo+0x69>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r14
je     11c5 <sd_echo+0x95>
mov    (%r12),%edi
mov    0x0(%r13,%rbx,8),%rdx
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
cmp    %rbp,%rbx
jae    1190 <sd_echo+0x60>
mov    (%r12),%edi
lea    0xe4a(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1190 <sd_echo+0x60>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
cmpq   $0x0,(%rsp)
je     11e5 <sd_echo+0xb5>
lea    0xe2c(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    11ea <sd_echo+0xba>
call   1050 <fflush@plt>
xor    %eax,%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"
@stdout = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @sd_echo(i32 %0, i8** %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%14 = load i32, i32* %9
%15 = load i32, i32* %10
%16 = load i32, i32* %11
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %5
store i32 0, i32* %6
br label %66
20: ; preds = %5
%21 = load i8**, i8*** %8
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i64 @xstrcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 1, i32* %12
br label %28
27: ; preds = %20
store i32 0, i32* %12
br label %28
28: ; preds = %27, %26
%29 = load i32, i32* %12
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 1, i32 0
store i32 %32, i32* %13
br label %33
33: ; preds = %53, %28
%34 = load i32, i32* %13
%35 = load i32, i32* %7
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %56
37: ; preds = %33
%38 = load i32, i32* @stdout
%39 = load i8**, i8*** %8
%40 = load i32, i32* %13
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %43)
%45 = load i32, i32* %13
%46 = load i32, i32* %7
%47 = sub nsw i32 %46, 1
%48 = icmp slt i32 %45, %47
br i1 %48, label %49, label %52
49: ; preds = %37
%50 = load i32, i32* @stdout
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %49, %37
br label %53
53: ; preds = %52
%54 = load i32, i32* %13
%55 = add nsw i32 %54, 1
store i32 %55, i32* %13
br label %33
56: ; preds = %33
%57 = load i32, i32* %12
%58 = icmp ne i32 %57, 0
br i1 %58, label %62, label %59
59: ; preds = %56
%60 = load i32, i32* @stdout
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %65
62: ; preds = %56
%63 = load i32, i32* @stdout
%64 = call i32 @fflush(i32 %63)
br label %65
65: ; preds = %62, %59
store i32 0, i32* %6
br label %66
66: ; preds = %65, %19
%67 = load i32, i32* %6
ret i32 %67
}

LLVM IR (-O2):
@.str = [3 x i8] c"-n\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @sd_echo(i32 %0, i8** nocapture %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %0, 1
br i1 %6, label %37, label %7
7: ; preds = %5
%8 = load i8*, i8** %1
%9 = tail call i64 @xstrcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = icmp ult i32 %11, %0
br i1 %12, label %13, label %31
13: ; preds = %7
%14 = add nsw i32 %0, -1
%15 = zext i1 %10 to i64
%16 = zext i32 %14 to i64
%17 = zext i32 %0 to i64
br label %18
18: ; preds = %13, %28
%19 = phi i64 [ %15, %13 ], [ %29, %28 ]
%20 = load i32, i32* @stdout
%21 = getelementptr inbounds i8*, i8** %1, i64 %19
%22 = load i8*, i8** %21
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = icmp ult i64 %19, %16
br i1 %24, label %25, label %28
25: ; preds = %18
%26 = load i32, i32* @stdout
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %18, %25
%29 = add nuw nsw i64 %19, 1
%30 = icmp eq i64 %29, %17
br i1 %30, label %31, label %18
31: ; preds = %28, %7
%32 = load i32, i32* @stdout
br i1 %10, label %35, label %33
33: ; preds = %31
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %37
35: ; preds = %31
%36 = tail call i32 @fflush(i32 %32)
br label %37
37: ; preds = %33, %35, %5
ret i32 0
}