#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 csub(int);
int fwrapper(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int arg, cres, fres;
  printf("Welcome to GNU libtool mixed C/Fortran demo!\n");
  arg = 2;
  cres = csub(arg);
  printf("The C subroutine returned, claiming that 2*%d = %d\n", arg, cres);
  if (cres == 2 * arg)
    printf("The C subroutine is ok!\n");
  printf("\nCalling the C wrapper routine...\n");
  fres = fwrapper(arg);
  printf("The C wrapper to the fortran subroutine returned,\n"
         "claiming that 2*%d = %d\n",
         arg, fres);
  if (fres == 2 * arg)
    printf("The Fortran 77 subroutine is ok!\n");
  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)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <csub@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jne    1199 <main+0x69>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1040 <fwrapper@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jne    11e5 <main+0xb5>
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf37(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1060 <csub@plt>
mov    %eax,%ebx
lea    0xea0(%rip),%rdi
mov    $0x2,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x4,%ebx
jne    117f <main+0x3f>
lea    0xf75(%rip),%rdi
call   1030 <puts@plt>
lea    0xf26(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1050 <fwrapper@plt>
mov    %eax,%ebx
lea    0xe96(%rip),%rdi
mov    $0x2,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x4,%ebx
jne    11bd <main+0x7d>
lea    0xf16(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Welcome to GNU libtool mixed C/Fortran demo!\0A\00"
@.str.1 = [52 x i8] c"The C subroutine returned, claiming that 2*%d = %d\0A\00"
@.str.2 = [25 x i8] c"The C subroutine is ok!\0A\00"
@.str.3 = [35 x i8] c"\0ACalling the C wrapper routine...\0A\00"
@.str.4 = [75 x i8] c"The C wrapper to the fortran subroutine returned,\0Aclaiming that 2*%d = %d\0A\00"
@.str.5 = [34 x i8] c"The Fortran 77 subroutine is ok!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %6
%10 = load i32, i32* %6
%11 = call i32 @csub(i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13)
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = mul nsw i32 2, %16
%18 = icmp eq i32 %15, %17
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32, i32* %6
%24 = call i32 @fwrapper(i32 %23)
store i32 %24, i32* %8
%25 = load i32, i32* %6
%26 = load i32, i32* %8
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0), i32 %25, i32 %26)
%28 = load i32, i32* %8
%29 = load i32, i32* %6
%30 = mul nsw i32 2, %29
%31 = icmp eq i32 %28, %30
br i1 %31, label %32, label %34
32: ; preds = %21
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
br label %34
34: ; preds = %32, %21
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [52 x i8] c"The C subroutine returned, claiming that 2*%d = %d\0A\00"
@.str.4 = [75 x i8] c"The C wrapper to the fortran subroutine returned,\0Aclaiming that 2*%d = %d\0A\00"
@str = [45 x i8] c"Welcome to GNU libtool mixed C/Fortran demo!\00"
@str.6 = [34 x i8] c"\0ACalling the C wrapper routine...\00"
@str.7 = [33 x i8] c"The Fortran 77 subroutine is ok!\00"
@str.8 = [24 x i8] c"The C subroutine is ok!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @csub(i32 2)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %4)
%6 = icmp eq i32 %4, 4
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.8, i64 0, i64 0))
br label %9
9: ; preds = %7, %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.6, i64 0, i64 0))
%11 = tail call i32 @fwrapper(i32 2)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0), i32 2, i32 %11)
%13 = icmp eq i32 %11, 4
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.7, i64 0, i64 0))
br label %16
16: ; preds = %14, %9
ret i32 0
}