#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 */
double atof(char *);
int /*<<< orphan*/ exit(int);
double hw1(double, double);
int /*<<< orphan*/ hw2(double, double);
int /*<<< orphan*/ hw3(double, double, double *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double r1, r2, s;
  if (argc < 3) {
    printf("Usage: %s r1 r2\n", argv[0]);
    exit(1);
  }
  r1 = atof(argv[1]);
  r2 = atof(argv[2]);
  printf("hw1, result: %g\n", hw1(r1, r2));
  printf("hw2, result: ");
  hw2(r1, r2);
  printf("hw3, result: ");
  hw3(r1, r2, &s);
  printf("%g\n", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    119f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1070 <hw1@plt>
lea    0xe38(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <hw2@plt>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    -0x28(%rbp),%rdi
call   1060 <hw3@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xdf4(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    120a <main+0xaa>
mov    0x8(%rbx),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x10(%rbx),%rdi
call   1040 <atof@plt>
movaps %xmm0,%xmm1
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <hw1@plt>
lea    0xe6d(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1030 <hw2@plt>
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x18(%rsp),%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1060 <hw3@plt>
movsd  0x18(%rsp),%xmm0
lea    0xe23(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
mov    (%rbx),%rsi
lea    0xdec(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"Usage: %s r1 r2\0A\00"
@.str.1 = [17 x i8] c"hw1, result: %g\0A\00"
@.str.2 = [14 x i8] c"hw2, result: \00"
@.str.3 = [14 x i8] c"hw3, result: \00"
@.str.4 = [4 x i8] c"%g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call double @atof(i8* %20)
store double %21, double* %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call double @atof(i8* %24)
store double %25, double* %7
%26 = load double, double* %6
%27 = load double, double* %7
%28 = call double @hw1(double %26, double %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), double %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%31 = load double, double* %6
%32 = load double, double* %7
%33 = call i32 @hw2(double %31, double %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%35 = load double, double* %6
%36 = load double, double* %7
%37 = call i32 @hw3(double %35, double %36, double* %8)
%38 = load double, double* %8
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Usage: %s r1 r2\0A\00"
@.str.1 = [17 x i8] c"hw1, result: %g\0A\00"
@.str.2 = [14 x i8] c"hw2, result: \00"
@.str.3 = [14 x i8] c"hw3, result: \00"
@.str.4 = [4 x i8] c"%g\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call double @atof(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call double @atof(i8* %15)
%17 = tail call double @hw1(double %13, double %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), double %17)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%20 = tail call i32 @hw2(double %13, double %16)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @hw3(double %13, double %16, double* %3)
%23 = load double, double* %3
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %23)
ret i32 0
}