#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*/ printf(char *, char, char *, char);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int xtermbar_main(int argc, char **argv) {
  char buff[512];
  argv++;
  argc--;
  buff[0] = '\0';
  while (argc--) {
    strcat(buff, *argv++);
    strcat(buff, " ");
  }
  buff[strlen(buff) - 1] = '\0';
  printf("%c]0;%s%c", (char)27, buff, (char)7);
  printf("%c]1;%s%c", (char)27, buff, (char)7);
  fflush(stdout);
  return 0;
}


x86 assembly (clang, -O0):
<xtermbar_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
movb   $0x0,-0x210(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     11b8 <xtermbar_main+0x78>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1060 <strcat@plt>
jmp    116e <xtermbar_main+0x2e>
lea    -0x210(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x210(%rbp,%rax,1)
lea    -0x210(%rbp),%rdx
lea    0xe23(%rip),%rdi
mov    $0x1b,%esi
mov    $0x7,%ecx
call   1040 <printf@plt>
lea    -0x210(%rbp),%rdx
lea    0xe10(%rip),%rdi
mov    $0x1b,%esi
mov    $0x7,%ecx
call   1040 <printf@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xtermbar_main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x200,%rsp
movb   $0x0,(%rsp)
cmp    $0x1,%edi
je     1190 <xtermbar_main+0x50>
mov    %rsi,%r14
mov    %edi,%r12d
mov    $0x1,%ebx
mov    %rsp,%r13
lea    0xe92(%rip),%r15
xchg   %ax,%ax
mov    (%r14,%rbx,8),%rsi
mov    %r13,%rdi
call   1060 <strcat@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1170 <xtermbar_main+0x30>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xe59(%rip),%rdi
mov    $0x1b,%esi
mov    %rbx,%rdx
mov    $0x7,%ecx
call   1040 <printf@plt>
lea    0xe4a(%rip),%rdi
mov    $0x1b,%esi
mov    %rbx,%rdx
mov    $0x7,%ecx
call   1040 <printf@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [10 x i8] c"%c]0;%s%c\00"
@.str.2 = [10 x i8] c"%c]1;%s%c\00"
@stdout = global i32 0
define i32 @xtermbar_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [512 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i8**, i8*** %4
%7 = getelementptr inbounds i8*, i8** %6, i32 1
store i8** %7, i8*** %4
%8 = load i32, i32* %3
%9 = add nsw i32 %8, -1
store i32 %9, i32* %3
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
store i8 0, i8* %10
br label %11
11: ; preds = %15, %2
%12 = load i32, i32* %3
%13 = add nsw i32 %12, -1
store i32 %13, i32* %3
%14 = icmp ne i32 %12, 0
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%17 = load i8**, i8*** %4
%18 = getelementptr inbounds i8*, i8** %17, i32 1
store i8** %18, i8*** %4
%19 = load i8*, i8** %17
%20 = call i32 @strcat(i8* %16, i8* %19)
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %11
23: ; preds = %11
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %27
store i8 0, i8* %28
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%30 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 27, i8* %29, i8 signext 7)
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%32 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8 signext 27, i8* %31, i8 signext 7)
%33 = load i32, i32* @stdout
%34 = call i32 @fflush(i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [10 x i8] c"%c]0;%s%c\00"
@.str.2 = [10 x i8] c"%c]1;%s%c\00"
@stdout = global i32 0
define i32 @xtermbar_main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
store i8 0, i8* %4
%5 = add nsw i32 %0, -1
%6 = icmp eq i32 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %2, %7
%8 = phi i32 [ %14, %7 ], [ %5, %2 ]
%9 = phi i8** [ %10, %7 ], [ %1, %2 ]
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strcat(i8* %4, i8* %11)
%13 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = add nsw i32 %8, -1
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %7
16: ; preds = %7, %2
%17 = call i32 @strlen(i8* %4)
%18 = add nsw i32 %17, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %19
store i8 0, i8* %20
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 27, i8* %4, i8 signext 7)
%22 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8 signext 27, i8* %4, i8 signext 7)
%23 = load i32, i32* @stdout
%24 = call i32 @fflush(i32 %23)
ret i32 0
}