#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 */
scalar_t__ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fread(double *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(double *, int, int, int /*<<< orphan*/);
double log(double);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  if (argc > 1) {
    fprintf(stderr, "Compute the log() operation to the input\n");
    fprintf(stderr, " < double input sequence > double output sequence\n");
    return 1;
  }
  for (;;) {
    double x, y;
    fread(&x, sizeof(double), 1, stdin);
    if (feof(stdin))
      break;
    y = log(x);
    fwrite(&y, sizeof(double), 1, stdout);
  }
  fprintf(stderr, "%s: done\n", argv[0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11aa <main+0x5a>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    123d <main+0xed>
jmp    11af <main+0x5f>
mov    0x2e32(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     11e8 <main+0x98>
jmp    1218 <main+0xc8>
movsd  -0x18(%rbp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,-0x20(%rbp)
mov    0x2dd2(%rip),%rax
mov    (%rax),%ecx
lea    -0x20(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1070 <fwrite@plt>
jmp    11af <main+0x5f>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jle    1193 <main+0x43>
mov    0x2e6f(%rip),%rbx
mov    (%rbx),%edi
lea    0xe8e(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xea8(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%ebx
jmp    1232 <main+0xe2>
mov    %rsi,%r14
mov    0x2e4b(%rip),%rbx
mov    (%rbx),%ecx
mov    %rsp,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    (%rbx),%edi
call   1050 <feof@plt>
test   %rax,%rax
jne    1216 <main+0xc6>
mov    0x2e0c(%rip),%r13
lea    0x8(%rsp),%r15
mov    %rsp,%r12
nopl   0x0(%rax)
movsd  (%rsp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x0(%r13),%ecx
mov    %r15,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1070 <fwrite@plt>
mov    (%rbx),%ecx
mov    %r12,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    (%rbx),%edi
call   1050 <feof@plt>
test   %rax,%rax
je     11d0 <main+0x80>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe34(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [42 x i8] c"Compute the log() operation to the input\0A\00"
@.str.1 = [51 x i8] c" < double input sequence > double output sequence\0A\00"
@stdin = global i32 0
@stdout = global i32 0
@.str.2 = [10 x i8] c"%s: done\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %34
15: ; preds = %2
br label %16
16: ; preds = %23, %15
%17 = load i32, i32* @stdin
%18 = call i32 @fread(double* %6, i32 8, i32 1, i32 %17)
%19 = load i32, i32* @stdin
%20 = call i64 @feof(i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %16
br label %28
23: ; preds = %16
%24 = load double, double* %6
%25 = call double @log(double %24)
store double %25, double* %7
%26 = load i32, i32* @stdout
%27 = call i32 @fwrite(double* %7, i32 8, i32 1, i32 %26)
br label %16
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %32)
store i32 0, i32* %3
br label %34
34: ; preds = %28, %10
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [42 x i8] c"Compute the log() operation to the input\0A\00"
@.str.1 = [51 x i8] c" < double input sequence > double output sequence\0A\00"
@stdin = global i32 0
@stdout = global i32 0
@.str.2 = [10 x i8] c"%s: done\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = alloca double
%5 = icmp sgt i32 %0, 1
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
%9 = load i32, i32* @stdin
%10 = call i32 @fread(double* %3, i32 8, i32 1, i32 %9)
%11 = load i32, i32* @stdin
%12 = call i64 @feof(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %19, label %29
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
br label %33
19: ; preds = %6, %19
%20 = load double, double* %3
%21 = call double @log(double %20)
store double %21, double* %4
%22 = load i32, i32* @stdout
%23 = call i32 @fwrite(double* %4, i32 8, i32 1, i32 %22)
%24 = load i32, i32* @stdin
%25 = call i32 @fread(double* %3, i32 8, i32 1, i32 %24)
%26 = load i32, i32* @stdin
%27 = call i64 @feof(i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %19, label %29
29: ; preds = %19, %6
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %1
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %29, %14
%34 = phi i32 [ 1, %14 ], [ 0, %29 ]
ret i32 %34
}