#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*/ atof(char *);
int /*<<< orphan*/ commas_in_double(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
scalar_t__ get_line(char *, int /*<<< orphan*/);
int /*<<< orphan*/ piece(char *, char, char *, int);
char *piece_replace(char *, char, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
void piece_commas_in_double(int piece_offset) {
  char buffer[1024];
  char piece_buffer[128];
  char results[128];
  while (get_line(buffer, stdin)) {
    if (!piece(piece_buffer, '^', buffer, piece_offset)) {
      fprintf(stderr, "%s: cannot get piece: %d in (%s)\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/timhriley/appaserver/refs/heads/"
              "master/utility/piece_commas_in_double.c",
              piece_offset, buffer);
      printf("%s\n", buffer);
      continue;
    }
    printf("%s\n", piece_replace(buffer, '^',
                                 commas_in_double(results, atof(piece_buffer)),
                                 piece_offset));
  }
}


x86 assembly (clang, -O0):
<piece_commas_in_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x520,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
call   1040 <get_line@plt>
cmp    $0x0,%rax
je     125f <piece_commas_in_double+0xef>
lea    -0x490(%rbp),%rdi
lea    -0x410(%rbp),%rdx
mov    -0x4(%rbp),%ecx
mov    $0x5e,%esi
call   1090 <piece@plt>
cmp    $0x0,%eax
jne    11ff <piece_commas_in_double+0x8f>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%ecx
lea    -0x410(%rbp),%r8
lea    0xe25(%rip),%rsi
lea    0xe40(%rip),%rdx
call   1060 <fprintf@plt>
lea    -0x410(%rbp),%rsi
lea    0xecf(%rip),%rdi
call   1050 <printf@plt>
jmp    117e <piece_commas_in_double+0xe>
lea    -0x410(%rbp),%rax
mov    %rax,-0x518(%rbp)
lea    -0x510(%rbp),%rax
mov    %rax,-0x520(%rbp)
lea    -0x490(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x520(%rbp),%rdi
mov    %eax,%esi
call   1080 <commas_in_double@plt>
mov    -0x518(%rbp),%rdi
mov    %eax,%edx
mov    -0x4(%rbp),%ecx
mov    $0x5e,%esi
call   1070 <piece_replace@plt>
mov    %rax,%rsi
lea    0xe6f(%rip),%rdi
call   1050 <printf@plt>
jmp    117e <piece_commas_in_double+0xe>
add    $0x520,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<piece_commas_in_double>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x508,%rsp
mov    %edi,%ebx
mov    0x2e5e(%rip),%r13
mov    0x0(%r13),%esi
lea    0x100(%rsp),%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     123e <piece_commas_in_double+0xce>
lea    0x80(%rsp),%r14
lea    0x100(%rsp),%r15
lea    0xf09(%rip),%rbp
mov    %rsp,%r12
jmp    11fd <piece_commas_in_double+0x8d>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
lea    0xe4b(%rip),%rdx
mov    %ebx,%ecx
mov    %r15,%r8
call   1060 <fprintf@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
mov    0x0(%r13),%esi
mov    %r15,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     123e <piece_commas_in_double+0xce>
mov    %r14,%rdi
mov    $0x5e,%esi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1090 <piece@plt>
test   %eax,%eax
je     11c0 <piece_commas_in_double+0x50>
mov    %r14,%rdi
call   1030 <atof@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1080 <commas_in_double@plt>
mov    %r15,%rdi
mov    $0x5e,%esi
mov    %eax,%edx
mov    %ebx,%ecx
call   1070 <piece_replace@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
jmp    11e7 <piece_commas_in_double+0x77>
add    $0x508,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@stderr = global i32 0
@.str = [34 x i8] c"%s: cannot get piece: %d in (%s)\0A\00"
@.str.1 = [162 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/timhriley/appaserver/refs/heads/master/utility/piece_commas_in_double.c\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @piece_commas_in_double(i32 %0) {
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca [128 x i8]
%5 = alloca [128 x i8]
store i32 %0, i32* %2
br label %6
6: ; preds = %24, %17, %1
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i64 @get_line(i8* %7, i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %33
11: ; preds = %6
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%14 = load i32, i32* %2
%15 = call i32 @piece(i8* %12, i8 signext 94, i8* %13, i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %11
%18 = load i32, i32* @stderr
%19 = load i32, i32* %2
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([162 x i8], [162 x i8]* @.str.1, i64 0, i64 0), i32 %19, i8* %20)
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %6
24: ; preds = %11
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%28 = call i32 @atof(i8* %27)
%29 = call i32 @commas_in_double(i8* %26, i32 %28)
%30 = load i32, i32* %2
%31 = call i8* @piece_replace(i8* %25, i8 signext 94, i32 %29, i32 %30)
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %31)
br label %6
33: ; preds = %6
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@stderr = global i32 0
@.str = [34 x i8] c"%s: cannot get piece: %d in (%s)\0A\00"
@.str.1 = [162 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/timhriley/appaserver/refs/heads/master/utility/piece_commas_in_double.c\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @piece_commas_in_double(i32 %0) {
%2 = alloca [1024 x i8]
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i64 @get_line(i8* %5, i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %27, label %11
11: ; preds = %1, %18
%12 = call i32 @piece(i8* %6, i8 signext 94, i8* %5, i32 %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([162 x i8], [162 x i8]* @.str.1, i64 0, i64 0), i32 %0, i8* %5)
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br label %18
18: ; preds = %14, %22
%19 = load i32, i32* @stdin
%20 = call i64 @get_line(i8* %5, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %27, label %11
22: ; preds = %11
%23 = call i32 @atof(i8* %6)
%24 = call i32 @commas_in_double(i8* %7, i32 %23)
%25 = call i8* @piece_replace(i8* %5, i8 signext 94, i32 %24, i32 %0)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %18
27: ; preds = %18, %1
ret void
}