#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*/ piece(char *, char, char *, int);
int /*<<< orphan*/ printf(char *, char *);
char *replace_piece(char *, char, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char *timlib_oracle_date2mysql_date_string(char *);
int main(int argc, char **argv) {
  int piece_offset;
  char input_buffer[1024];
  char piece_buffer[128];
  char *date_string;
  char delimiter;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s piece_offset delimiter\n", argv[0]);
    exit(1);
  }
  piece_offset = atoi(argv[1]);
  delimiter = *argv[2];
  while (get_line(input_buffer, stdin)) {
    if (!piece(piece_buffer, delimiter, input_buffer, piece_offset)) {
      printf("%s\n", input_buffer);
      continue;
    }
    date_string = timlib_oracle_date2mysql_date_string(piece_buffer);
    printf("%s\n",
           replace_piece(input_buffer, delimiter, date_string, piece_offset));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11c9 <main+0x49>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe46(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%al
mov    %al,-0x4a9(%rbp)
lea    -0x420(%rbp),%rdi
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
call   1030 <get_line@plt>
cmp    $0x0,%rax
je     128e <main+0x10e>
lea    -0x4a0(%rbp),%rdi
mov    -0x4a9(%rbp),%al
lea    -0x420(%rbp),%rdx
mov    -0x14(%rbp),%ecx
movsbl %al,%esi
call   1090 <piece@plt>
cmp    $0x0,%eax
jne    1248 <main+0xc8>
lea    -0x420(%rbp),%rsi
lea    0xde4(%rip),%rdi
call   1040 <printf@plt>
jmp    11e9 <main+0x69>
lea    -0x4a0(%rbp),%rdi
call   1050 <timlib_oracle_date2mysql_date_string@plt>
mov    %rax,-0x4a8(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x4a9(%rbp),%al
mov    -0x4a8(%rbp),%rdx
mov    -0x14(%rbp),%ecx
movsbl %al,%esi
call   10a0 <replace_piece@plt>
mov    %rax,%rsi
lea    0xd9e(%rip),%rdi
call   1040 <printf@plt>
jmp    11e9 <main+0x69>
xor    %eax,%eax
add    $0x4b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x488,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1254 <main+0xd4>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%r15d
mov    0x10(%rbx),%rax
mov    (%rax),%bl
mov    0x2e32(%rip),%r13
mov    0x0(%r13),%esi
lea    0x80(%rsp),%rdi
call   1030 <get_line@plt>
test   %rax,%rax
je     1240 <main+0xc0>
movsbl %bl,%ebp
mov    %rsp,%r14
lea    0x80(%rsp),%rbx
lea    0xe41(%rip),%r12
jmp    120c <main+0x8c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    0x0(%r13),%esi
mov    %rbx,%rdi
call   1030 <get_line@plt>
test   %rax,%rax
je     1240 <main+0xc0>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %r15d,%ecx
call   1090 <piece@plt>
test   %eax,%eax
je     11f0 <main+0x70>
mov    %r14,%rdi
call   1050 <timlib_oracle_date2mysql_date_string@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
mov    %r15d,%ecx
call   10a0 <replace_piece@plt>
mov    %r12,%rdi
mov    %rax,%rsi
jmp    11f6 <main+0x76>
xor    %eax,%eax
add    $0x488,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd99(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: %s piece_offset delimiter\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 i32
%7 = alloca [1024 x i8]
%8 = alloca [128 x i8]
%9 = alloca i8*
%10 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = load i8, i8* %27
store i8 %28, i8* %10
br label %29
29: ; preds = %44, %41, %20
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%31 = load i32, i32* @stdin
%32 = call i64 @get_line(i8* %30, i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %53
34: ; preds = %29
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%36 = load i8, i8* %10
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%38 = load i32, i32* %6
%39 = call i32 @piece(i8* %35, i8 signext %36, i8* %37, i32 %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %34
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %42)
br label %29
44: ; preds = %34
%45 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%46 = call i8* @timlib_oracle_date2mysql_date_string(i8* %45)
store i8* %46, i8** %9
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%48 = load i8, i8* %10
%49 = load i8*, i8** %9
%50 = load i32, i32* %6
%51 = call i8* @replace_piece(i8* %47, i8 signext %48, i8* %49, i32 %50)
%52 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %51)
br label %29
53: ; preds = %29
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: %s piece_offset delimiter\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 [1024 x i8]
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 3
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = load i8, i8* %18
%20 = load i32, i32* @stdin
%21 = call i64 @get_line(i8* %5, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %36, label %23
23: ; preds = %13, %28
%24 = call i32 @piece(i8* %6, i8 signext %19, i8* %5, i32 %16)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %28
28: ; preds = %26, %32
%29 = load i32, i32* @stdin
%30 = call i64 @get_line(i8* %5, i32 %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %36, label %23
32: ; preds = %23
%33 = call i8* @timlib_oracle_date2mysql_date_string(i8* %6)
%34 = call i8* @replace_piece(i8* %5, i8 signext %19, i8* %33, i32 %16)
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %34)
br label %28
36: ; preds = %28, %13
ret i32 0
}