#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 M_PI;
int pow(float, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
void cylinder_surface_area() {
  float r, h, sa;
  printf("Radius of cylinder: ");
  scanf("%f", &r);
  printf("Height of cylinder: ");
  scanf("%f", &h);
  sa = ((2 * M_PI * r) * h) + ((M_PI * pow(r, 2) * 2));
  printf("Surface area is: %f", sa);
  printf("\n");
}


x86 assembly (clang, -O0):
<cylinder_surface_area>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
movss  -0x18(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
imul   %ecx,%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe41(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cylinder_surface_area>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee1(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%ebx
add    %ebx,%ebx
cvtsi2ss %ebx,%xmm1
movss  0xc(%rsp),%xmm0
mulss  %xmm0,%xmm1
mulss  0x8(%rsp),%xmm1
movss  %xmm1,0x4(%rsp)
mov    $0x2,%edi
call   1060 <pow@plt>
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Radius of cylinder: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [21 x i8] c"Height of cylinder: \00"
@M_PI = global i32 0
@.str.3 = [20 x i8] c"Surface area is: %f\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @cylinder_surface_area() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%8 = load i32, i32* @M_PI
%9 = mul nsw i32 2, %8
%10 = sitofp i32 %9 to float
%11 = load float, float* %1
%12 = fmul float %10, %11
%13 = load float, float* %2
%14 = load i32, i32* @M_PI
%15 = load float, float* %1
%16 = call i32 @pow(float %15, i32 2)
%17 = mul nsw i32 %14, %16
%18 = mul nsw i32 %17, 2
%19 = sitofp i32 %18 to float
%20 = call float @llvm.fmuladd.f32(float %12, float %13, float %19)
store float %20, float* %3
%21 = load float, float* %3
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), double %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"Radius of cylinder: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [21 x i8] c"Height of cylinder: \00"
@M_PI = global i32 0
@.str.3 = [20 x i8] c"Surface area is: %f\00"
define void @cylinder_surface_area() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%9 = load i32, i32* @M_PI
%10 = shl i32 %9, 1
%11 = sitofp i32 %10 to float
%12 = load float, float* %1
%13 = fmul float %12, %11
%14 = load float, float* %2
%15 = call i32 @pow(float %12, i32 2)
%16 = mul i32 %10, %15
%17 = sitofp i32 %16 to float
%18 = call float @llvm.fmuladd.f32(float %13, float %14, float %17)
%19 = fpext float %18 to double
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), double %19)
%21 = call i32 @putchar(i32 10)
ret void
}