#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*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char *timlib_search_replace_character_limited(char *, char, char, int);
int main(int argc, char **argv) {
  char buffer[2048];
  char search_delimiter;
  char replace_delimiter;
  int how_many;
  if (argc != 4) {
    fprintf(stderr, "Usage: %s: search_delimiter replace_delimiter how_many\n",
            argv[0]);
    exit(1);
  }
  search_delimiter = *argv[1];
  replace_delimiter = *argv[2];
  how_many = atoi(argv[3]);
  while (get_line(buffer, stdin)) {
    printf("%s\n", timlib_search_replace_character_limited(
                       buffer, search_delimiter, replace_delimiter, how_many));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%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,-0x811(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%al
mov    %al,-0x812(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x818(%rbp)
lea    -0x810(%rbp),%rdi
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
call   1040 <get_line@plt>
cmp    $0x0,%rax
je     1233 <main+0xd3>
lea    -0x810(%rbp),%rdi
mov    -0x811(%rbp),%dl
mov    -0x812(%rbp),%al
mov    -0x818(%rbp),%ecx
movsbl %dl,%esi
movsbl %al,%edx
call   1030 <timlib_search_replace_character_limited@plt>
mov    %rax,%rsi
lea    0xe0f(%rip),%rdi
call   1050 <printf@plt>
jmp    11dc <main+0x7c>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
cmp    $0x4,%edi
jne    1200 <main+0xa0>
mov    0x8(%rsi),%rax
mov    0x10(%rsi),%rcx
mov    (%rax),%bl
mov    (%rcx),%bpl
mov    0x18(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
mov    0x2e4e(%rip),%r13
mov    0x0(%r13),%esi
mov    %rsp,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     11ec <main+0x8c>
movsbl %bl,%r15d
movsbl %bpl,%ebx
mov    %rsp,%rbp
lea    0xe7b(%rip),%r12
nopl   (%rax)
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
call   1030 <timlib_search_replace_character_limited@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    11c0 <main+0x60>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xded(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [56 x i8] c"Usage: %s: search_delimiter replace_delimiter how_many\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 [2048 x i8]
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32
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 ([56 x i8], [56 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* %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = load i8, i8* %26
store i8 %27, i8* %8
%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* %9
br label %32
32: ; preds = %37, %19
%33 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, 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 [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%39 = load i8, i8* %7
%40 = load i8, i8* %8
%41 = load i32, i32* %9
%42 = call i8* @timlib_search_replace_character_limited(i8* %38, i8 signext %39, i8 signext %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 = [56 x i8] c"Usage: %s: search_delimiter replace_delimiter how_many\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 [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 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 ([56 x i8], [56 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 = load i8, 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* @timlib_search_replace_character_limited(i8* %4, i8 signext %14, i8 signext %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
}