#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 */
float calc_resistance(int, char, float *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int count = 3;
  char conn = 'p';
  float array[] = {25, 35, 70};
  float resistance = calc_resistance(count, conn, array);
  printf("Test program for libresistance \n");
  printf("%f", resistance);
  printf("\nEnd.");
  return (1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movb   $0x70,-0x9(%rbp)
mov    0xebf(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xebd(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x9(%rbp),%al
lea    -0x18(%rbp),%rdx
movsbl %al,%esi
call   1030 <calc_resistance@plt>
movss  %xmm0,-0x1c(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xeaa(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    0xece(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xebb(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdx
mov    $0x3,%edi
mov    $0x70,%esi
call   1040 <calc_resistance@plt>
movss  %xmm0,0x4(%rsp)
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.array = [3 x float] [float 2.500000e+01, float 3.500000e+01, float 7.000000e+01]
@.str = [33 x i8] c"Test program for libresistance \0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [6 x i8] c"\0AEnd.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca [3 x float]
%5 = alloca float
store i32 0, i32* %1
store i32 3, i32* %2
store i8 112, i8* %3
%6 = bitcast [3 x float]* %4 to i8*
%7 = load i32, i32* %2
%8 = load i8, i8* %3
%9 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 0
%10 = call float @calc_resistance(i32 %7, i8 signext %8, float* %9)
store float %10, float* %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%12 = load float, float* %5
%13 = fpext float %12 to double
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@__const.main.array = [3 x float] [float 2.500000e+01, float 3.500000e+01, float 7.000000e+01]
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [6 x i8] c"\0AEnd.\00"
@str = [32 x i8] c"Test program for libresistance \00"
define i32 @main() {
%1 = alloca [3 x float]
%2 = bitcast [3 x float]* %1 to i8*
%3 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 0
%4 = call float @calc_resistance(i32 3, i8 signext 112, float* %3)
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%6 = fpext float %4 to double
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 1
}