#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 /*<<< orphan*/ blacs_exit_(int const *);
int /*<<< orphan*/ blacs_get_(int const *, int const *, int *);
int /*<<< orphan*/ blacs_gridexit_(int *);
int /*<<< orphan*/ blacs_gridinfo_(int *, int *, int *, int *, int *);
int /*<<< orphan*/ blacs_gridinit_(int *, char *, int *, int const *);
int /*<<< orphan*/ blacs_pinfo_(int *, int *);
int /*<<< orphan*/ printf(char *, float);
float pslamch_(int *, char *);
int main(void) {
  int myid, nprocs, ictxt, mycol, myrow, npcol = 2, nprow = 2;
  const int i0 = 0, i1 = 1, in1 = -1;
  blacs_pinfo_(&myid, &nprocs);
  blacs_get_(&in1, &i0, &ictxt);
  blacs_gridinit_(&ictxt, "C", &nprocs, &i1);
  blacs_gridinfo_(&ictxt, &nprow, &npcol, &myrow, &mycol);
  float eps = pslamch_(&ictxt, "E");
  if (myrow == mycol)
    printf("OK: Scalapack C: eps= %f\n", eps);
  blacs_gridexit_(&ictxt);
  blacs_exit_(&i0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <blacs_pinfo_@plt>
lea    -0x2c(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   10a0 <blacs_get_@plt>
lea    -0x10(%rbp),%rdi
lea    0xe25(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1060 <blacs_gridinit_@plt>
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1070 <blacs_gridinfo_@plt>
lea    -0x10(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1080 <pslamch_@plt>
movss  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1233 <main+0xb3>
movss  -0x30(%rbp),%xmm0
lea    0xdd6(%rip),%rdi
call   1040 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1090 <blacs_gridexit_@plt>
lea    -0x24(%rbp),%rdi
call   1050 <blacs_exit_@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movl   $0x2,0x10(%rsp)
movl   $0x2,0xc(%rsp)
movl   $0x0,(%rsp)
movl   $0x1,0x8(%rsp)
movl   $0xffffffff,0x4(%rsp)
ff
lea    0x24(%rsp),%rdi
lea    0x20(%rsp),%r14
mov    %r14,%rsi
call   1030 <blacs_pinfo_@plt>
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
lea    0x1c(%rsp),%rbx
mov    %rbx,%rdx
call   10a0 <blacs_get_@plt>
lea    0xe24(%rip),%rsi
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <blacs_gridinit_@plt>
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x18(%rsp),%r8
mov    %rbx,%rdi
call   1070 <blacs_gridinfo_@plt>
lea    0xdf3(%rip),%rsi
mov    %rbx,%rdi
call   1080 <pslamch_@plt>
mov    0x14(%rsp),%eax
cmp    0x18(%rsp),%eax
jne    122d <main+0xad>
lea    0xddc(%rip),%rdi
call   1040 <printf@plt>
lea    0x1c(%rsp),%rdi
call   1090 <blacs_gridexit_@plt>
mov    %rsp,%rdi
call   1050 <blacs_exit_@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"C\00"
@.str.1 = [2 x i8] c"E\00"
@.str.2 = [26 x i8] c"OK: Scalapack C: eps= %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float
store i32 0, i32* %1
store i32 2, i32* %7
store i32 2, i32* %8
store i32 0, i32* %9
store i32 1, i32* %10
store i32 -1, i32* %11
%13 = call i32 @blacs_pinfo_(i32* %2, i32* %3)
%14 = call i32 @blacs_get_(i32* %11, i32* %9, i32* %4)
%15 = call i32 @blacs_gridinit_(i32* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %10)
%16 = call i32 @blacs_gridinfo_(i32* %4, i32* %8, i32* %7, i32* %6, i32* %5)
%17 = call float @pslamch_(i32* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store float %17, float* %12
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %0
%22 = load float, float* %12
%23 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), float %22)
br label %24
24: ; preds = %21, %0
%25 = call i32 @blacs_gridexit_(i32* %4)
%26 = call i32 @blacs_exit_(i32* %9)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"C\00"
@.str.1 = [2 x i8] c"E\00"
@.str.2 = [26 x i8] c"OK: Scalapack C: eps= %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = bitcast i32* %1 to i8*
%12 = bitcast i32* %2 to i8*
%13 = bitcast i32* %3 to i8*
%14 = bitcast i32* %4 to i8*
%15 = bitcast i32* %5 to i8*
%16 = bitcast i32* %6 to i8*
store i32 2, i32* %6
%17 = bitcast i32* %7 to i8*
store i32 2, i32* %7
%18 = bitcast i32* %8 to i8*
store i32 0, i32* %8
%19 = bitcast i32* %9 to i8*
store i32 1, i32* %9
%20 = bitcast i32* %10 to i8*
store i32 -1, i32* %10
%21 = call i32 @blacs_pinfo_(i32* %1, i32* %2)
%22 = call i32 @blacs_get_(i32* %10, i32* %8, i32* %3)
%23 = call i32 @blacs_gridinit_(i32* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %9)
%24 = call i32 @blacs_gridinfo_(i32* %3, i32* %7, i32* %6, i32* %5, i32* %4)
%25 = call float @pslamch_(i32* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* %5
%27 = load i32, i32* %4
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %0
%30 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), float %25)
br label %31
31: ; preds = %29, %0
%32 = call i32 @blacs_gridexit_(i32* %3)
%33 = call i32 @blacs_exit_(i32* %8)
ret i32 0
}