#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 */
struct Molecule_t {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int get_nElectron(struct Molecule_t *);
int /*<<< orphan*/ printf(char *);
int get_nEA(struct Molecule_t *mol, int M) {
  int N;
  N = get_nElectron(mol);
  if ((N + M - 1) % 2 == 1) {
    printf("get_nEA - error number of electron does not match multiplicity\n");
    exit(-1);
  }
  return (N + M - 1) / 2;
}


x86 assembly (clang, -O0):
<get_nEA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <get_nElectron@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    117b <get_nEA+0x4b>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_nEA>:
push   %rbx
mov    %esi,%ebx
call   1040 <get_nElectron@plt>
mov    %ebx,%ecx
add    %eax,%ecx
lea    (%rbx,%rax,1),%edx
add    $0xffffffff,%edx
mov    %edx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%edx
cmp    $0x1,%edx
je     115c <get_nEA+0x2c>
sar    %eax
pop    %rbx
ret
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.Molecule_t = type { i32 }
@.str = [64 x i8] c"get_nEA - error number of electron does not match multiplicity\0A\00"
define i32 @get_nEA(%struct.Molecule_t* %0, i32 %1) {
%3 = alloca %struct.Molecule_t*
%4 = alloca i32
%5 = alloca i32
store %struct.Molecule_t* %0, %struct.Molecule_t** %3
store i32 %1, i32* %4
%6 = load %struct.Molecule_t*, %struct.Molecule_t** %3
%7 = call i32 @get_nElectron(%struct.Molecule_t* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = add nsw i32 %8, %9
%11 = sub nsw i32 %10, 1
%12 = srem i32 %11, 2
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %2
%18 = load i32, i32* %5
%19 = load i32, i32* %4
%20 = add nsw i32 %18, %19
%21 = sub nsw i32 %20, 1
%22 = sdiv i32 %21, 2
ret i32 %22
}

LLVM IR (-O2):
%struct.Molecule_t = type { i32 }
@str = [63 x i8] c"get_nEA - error number of electron does not match multiplicity\00"
define i32 @get_nEA(%struct.Molecule_t* %0, i32 %1) {
%3 = tail call i32 @get_nElectron(%struct.Molecule_t* %0)
%4 = add i32 %1, -1
%5 = add i32 %4, %3
%6 = srem i32 %5, 2
%7 = sdiv i32 %5, 2
%8 = icmp eq i32 %6, 1
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
ret i32 %7
}