#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*/ do_work_on_buffer(char *, char *);
scalar_t__ get_line(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
void piece_set_character(int argc, char **argv) {
  char buffer[1024];
  int local_argc;
  char **local_argv;
  while (get_line(buffer, stdin)) {
    local_argc = argc;
    local_argv = argv;
    while (--local_argc)
      do_work_on_buffer(*++local_argv, buffer);
    printf("%s\n", buffer);
  }
}


x86 assembly (clang, -O0):
<piece_set_character>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
call   1030 <get_line@plt>
cmp    $0x0,%rax
je     11cf <piece_set_character+0x9f>
mov    -0x4(%rbp),%eax
mov    %eax,-0x414(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x420(%rbp)
mov    -0x414(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x414(%rbp)
cmp    $0x0,%eax
je     11b7 <piece_set_character+0x87>
mov    -0x420(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x420(%rbp)
mov    0x8(%rax),%rdi
lea    -0x410(%rbp),%rsi
call   1040 <do_work_on_buffer@plt>
jmp    1175 <piece_set_character+0x45>
lea    -0x410(%rbp),%rsi
lea    0xe3b(%rip),%rdi
call   1050 <printf@plt>
jmp    1142 <piece_set_character+0x12>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<piece_set_character>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rbx
mov    %edi,%r15d
mov    0x2e9a(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
call   1030 <get_line@plt>
test   %rax,%rax
je     11b7 <piece_set_character+0x87>
mov    %r15d,%ebp
add    $0xffffffff,%r15d
lea    0xe95(%rip),%r14
mov    %rsp,%r13
jmp    1191 <piece_set_character+0x61>
mov    %r14,%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
call   1030 <get_line@plt>
test   %rax,%rax
je     11b7 <piece_set_character+0x87>
test   %r15d,%r15d
je     1170 <piece_set_character+0x40>
mov    $0x1,%r12d
nopl   0x0(%rax)
mov    (%rbx,%r12,8),%rdi
mov    %r13,%rsi
call   1040 <do_work_on_buffer@plt>
add    $0x1,%r12
cmp    %r12d,%ebp
jne    11a0 <piece_set_character+0x70>
jmp    1170 <piece_set_character+0x40>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define void @piece_set_character(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
br label %8
8: ; preds = %26, %2
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i64 @get_line(i8* %9, i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %8
%14 = load i32, i32* %3
store i32 %14, i32* %6
%15 = load i8**, i8*** %4
store i8** %15, i8*** %7
br label %16
16: ; preds = %20, %13
%17 = load i32, i32* %6
%18 = add nsw i32 %17, -1
store i32 %18, i32* %6
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i8**, i8*** %7
%22 = getelementptr inbounds i8*, i8** %21, i32 1
store i8** %22, i8*** %7
%23 = load i8*, i8** %22
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%25 = call i32 @do_work_on_buffer(i8* %23, i8* %24)
br label %16
26: ; preds = %16
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %27)
br label %8
29: ; preds = %8
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define void @piece_set_character(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i64 @get_line(i8* %4, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %25, label %8
8: ; preds = %2
%9 = add nsw i32 %0, -1
%10 = icmp eq i32 %9, 0
br label %11
11: ; preds = %8, %20
br i1 %10, label %20, label %12
12: ; preds = %11, %12
%13 = phi i32 [ %18, %12 ], [ %9, %11 ]
%14 = phi i8** [ %15, %12 ], [ %1, %11 ]
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @do_work_on_buffer(i8* %16, i8* %4)
%18 = add nsw i32 %13, -1
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %12
20: ; preds = %12, %11
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%22 = load i32, i32* @stdin
%23 = call i64 @get_line(i8* %4, i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %11
25: ; preds = %20, %2
ret void
}