#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*/ cdoAbort(char *);
int /*<<< orphan*/ fac(int, int *, int *);
int nlat2nlon(int nlat) {
  int nlon, m, ierr;
  if (nlat == 0)
    cdoAbort("nlat = 0!");
  nlon = 2 * nlat;
  fac(nlon, &m, &ierr);
  while (ierr != 0) {
    nlon = m;
    while (nlon % 4 != 0)
      nlon++;
    fac(nlon, &m, &ierr);
  }
  return (nlon);
}


x86 assembly (clang, -O0):
<nlat2nlon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1141 <nlat2nlon+0x21>
lea    0xec4(%rip),%rdi
call   1040 <cdoAbort@plt>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <fac@plt>
cmpl   $0x0,-0x10(%rbp)
je     11a1 <nlat2nlon+0x81>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     118c <nlat2nlon+0x6c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116a <nlat2nlon+0x4a>
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <fac@plt>
jmp    115a <nlat2nlon+0x3a>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nlat2nlon>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
test   %edi,%edi
jne    113b <nlat2nlon+0x1b>
lea    0xeca(%rip),%rdi
call   1040 <cdoAbort@plt>
add    %ebx,%ebx
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1030 <fac@plt>
cmpl   $0x0,0x8(%rsp)
je     1181 <nlat2nlon+0x61>
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
nop
mov    0xc(%rsp),%eax
mov    %eax,%ebx
neg    %ebx
and    $0x3,%ebx
add    %eax,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fac@plt>
cmpl   $0x0,0x8(%rsp)
jne    1160 <nlat2nlon+0x40>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"nlat = 0!\00"
define i32 @nlat2nlon(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @cdoAbort(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = load i32, i32* %2
%12 = mul nsw i32 2, %11
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = call i32 @fac(i32 %13, i32* %4, i32* %5)
br label %15
15: ; preds = %27, %10
%16 = load i32, i32* %5
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %15
%19 = load i32, i32* %4
store i32 %19, i32* %3
br label %20
20: ; preds = %24, %18
%21 = load i32, i32* %3
%22 = srem i32 %21, 4
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %20
27: ; preds = %20
%28 = load i32, i32* %3
%29 = call i32 @fac(i32 %28, i32* %4, i32* %5)
br label %15
30: ; preds = %15
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [10 x i8] c"nlat = 0!\00"
define i32 @nlat2nlon(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = icmp eq i32 %0, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 @cdoAbort(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
%10 = shl nsw i32 %0, 1
%11 = call i32 @fac(i32 %10, i32* %2, i32* %3)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %9, %14
%15 = load i32, i32* %2
%16 = sub i32 0, %15
%17 = and i32 %16, 3
%18 = add i32 %15, %17
%19 = call i32 @fac(i32 %18, i32* %2, i32* %3)
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %14
22: ; preds = %14, %9
%23 = phi i32 [ %10, %9 ], [ %18, %14 ]
ret i32 %23
}