#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ get_line(char *, int /*<<< orphan*/);
char *piece_swap(char *, char, int, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char delimiter;
  int piece1_offset, piece2_offset;
  char input_buffer[4096];
  if (argc != 4) {
    fprintf(stderr, "Usage: %s delimiter piece1_offset piece2_offset\n",
            argv[0]);
    exit(1);
  }
  delimiter = *argv[1];
  piece1_offset = atoi(argv[2]);
  piece2_offset = atoi(argv[3]);
  while (get_line(input_buffer, stdin)) {
    printf("%s\n",
           piece_swap(input_buffer, delimiter, piece1_offset, piece2_offset));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11a9 <main+0x49>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe66(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x1020(%rbp),%rdi
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
call   1040 <get_line@plt>
cmp    $0x0,%rax
je     1221 <main+0xc1>
lea    -0x1020(%rbp),%rdi
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
movsbl %al,%esi
call   1030 <piece_swap@plt>
mov    %rax,%rsi
lea    0xe1a(%rip),%rdi
call   1050 <printf@plt>
jmp    11d6 <main+0x76>
xor    %eax,%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    1210 <main+0xb0>
mov    0x8(%rbx),%rax
mov    0x10(%rbx),%rdi
mov    (%rax),%bpl
call   1070 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%r15d
mov    0x2e45(%rip),%r13
mov    0x0(%r13),%esi
mov    %rsp,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     11fc <main+0x9c>
movsbl %bpl,%ebx
mov    %rsp,%rbp
lea    0xe6f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %r15d,%ecx
call   1030 <piece_swap@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    0x0(%r13),%esi
mov    %rbp,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
jne    11d0 <main+0x70>
xor    %eax,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xddd(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [49 x i8] c"Usage: %s delimiter piece1_offset piece2_offset\0A\00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca [4096 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 4
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = load i8, i8* %22
store i8 %23, i8* %6
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %7
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %8
br label %32
32: ; preds = %37, %19
%33 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%34 = load i32, i32* @stdin
%35 = call i64 @get_line(i8* %33, i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %44
37: ; preds = %32
%38 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%39 = load i8, i8* %6
%40 = load i32, i32* %7
%41 = load i32, i32* %8
%42 = call i8* @piece_swap(i8* %38, i8 signext %39, i32 %40, i32 %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %42)
br label %32
44: ; preds = %32
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [49 x i8] c"Usage: %s delimiter piece1_offset piece2_offset\0A\00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 4
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = load i32, i32* @stdin
%22 = call i64 @get_line(i8* %4, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %30, label %24
24: ; preds = %11, %24
%25 = call i8* @piece_swap(i8* %4, i8 signext %14, i32 %17, i32 %20)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @stdin
%28 = call i64 @get_line(i8* %4, i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %24
30: ; preds = %24, %11
ret i32 0
}