#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*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int Gregorian2Julian(int d, int m, int y, int *jd) {
  char ystr[3] = "";
  *jd = 0;
  if (d < 1 || d > 31)
    return -1;
  if (m < 1 || m > 12)
    return -1;
  if (y > 0 && y < 100) {
    if (y < 10)
      sprintf(ystr, "0%d", y);
    else
      sprintf(ystr, "%d", y);
    fprintf(stderr, "Warning: Gregorian2Julian() has been called for year %s\n",
            ystr);
    fprintf(stderr, "Maybe you meant 19%s or 20%s?\n", ystr, ystr);
  }
  *jd = (1461 * (y + 4800 + (m - 14) / 12)) / 4 +
        (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 -
        (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 + d - 32075;
  return 0;
}


x86 assembly (clang, -O0):
<Gregorian2Julian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
lea    -0x1b(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <memset@plt>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
cmpl   $0x1,-0x8(%rbp)
jl     1173 <Gregorian2Julian+0x43>
cmpl   $0x1f,-0x8(%rbp)
jle    117f <Gregorian2Julian+0x4f>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ce <Gregorian2Julian+0x19e>
cmpl   $0x1,-0xc(%rbp)
jl     1193 <Gregorian2Julian+0x63>
cmpl   $0xc,-0xc(%rbp)
jle    119f <Gregorian2Julian+0x6f>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ce <Gregorian2Julian+0x19e>
cmpl   $0x0,-0x10(%rbp)
jle    1222 <Gregorian2Julian+0xf2>
cmpl   $0x64,-0x10(%rbp)
jge    1222 <Gregorian2Julian+0xf2>
cmpl   $0xa,-0x10(%rbp)
jge    11d5 <Gregorian2Julian+0xa5>
lea    -0x1b(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe35(%rip),%rsi
call   1050 <sprintf@plt>
jmp    11e8 <Gregorian2Julian+0xb8>
lea    -0x1b(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe1e(%rip),%rsi
call   1050 <sprintf@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
lea    -0x1b(%rbp),%rdx
lea    0xe08(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    -0x1b(%rbp),%rdx
lea    -0x1b(%rbp),%rcx
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x12c0,%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
sub    $0xe,%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
imul   $0x5b5,%eax,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
sub    $0xe,%eax
mov    $0xc,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x24(%rbp),%eax
imul   $0xc,%edx,%edx
sub    %edx,%eax
imul   $0x16f,%eax,%eax
mov    $0xc,%esi
cltd
idiv   %esi
add    %eax,%ecx
mov    -0x10(%rbp),%eax
add    $0x1324,%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
sub    $0xe,%eax
mov    $0xc,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x20(%rbp),%eax
add    %edx,%eax
mov    $0x64,%esi
cltd
idiv   %esi
imul   $0x3,%eax,%eax
mov    $0x4,%esi
cltd
idiv   %esi
sub    %eax,%ecx
add    -0x8(%rbp),%ecx
sub    $0x7d4b,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Gregorian2Julian>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edi,%r15d
movb   $0x0,0x6(%rsp)
movw   $0x0,0x4(%rsp)
movl   $0x0,(%rcx)
lea    -0x20(%r15),%ecx
mov    $0xffffffff,%eax
cmp    $0xffffffe1,%ecx
jb     125a <Gregorian2Julian+0x13a>
mov    %esi,%r12d
lea    -0xd(%r12),%ecx
cmp    $0xfffffff4,%ecx
jb     125a <Gregorian2Julian+0x13a>
mov    %edx,%ebx
lea    -0x1(%rbx),%eax
cmp    $0x62,%eax
ja     11c6 <Gregorian2Julian+0xa6>
cmp    $0xa,%ebx
lea    0xe86(%rip),%rax
lea    0xe80(%rip),%rsi
cmovb  %rax,%rsi
lea    0x4(%rsp),%r13
mov    %r13,%rdi
mov    %ebx,%edx
call   1040 <sprintf@plt>
mov    0x2e45(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe5f(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe84(%rip),%rsi
mov    %r13,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0xe,%al
sub    %r12b,%al
movzbl %al,%eax
imul   $0xab,%eax,%ecx
shr    $0xb,%ecx
sub    %ecx,%ebx
imul   $0x5b5,%ebx,%eax
lea    0x6b01c0(%rax),%edx
add    $0x6b01c3,%eax
test   %edx,%edx
cmovns %edx,%eax
sar    $0x2,%eax
lea    (%rcx,%rcx,2),%ecx
lea    (%r12,%rcx,4),%ecx
imul   $0x16f,%ecx,%ecx
add    $0xfffffd22,%ecx
movswl %cx,%ecx
imul   $0x2aab,%ecx,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x11,%ecx
add    %edx,%ecx
add    $0x1324,%ebx
movslq %ebx,%rdx
imul   $0x51eb851f,%rdx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x25,%rdx
add    %esi,%edx
lea    (%rdx,%rdx,2),%esi
lea    (%rdx,%rdx,2),%edx
add    $0x3,%edx
test   %esi,%esi
cmovns %esi,%edx
sar    $0x2,%edx
add    %eax,%r15d
sub    %edx,%r15d
lea    (%r15,%rcx,1),%eax
add    $0xffff82b5,%eax
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"0%d\00"
@.str.1 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.2 = [57 x i8] c"Warning: Gregorian2Julian() has been called for year %s\0A\00"
@.str.3 = [31 x i8] c"Maybe you meant 19%s or 20%s?\0A\00"
define i32 @Gregorian2Julian(i32 %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca [3 x i8]
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%11 = bitcast [3 x i8]* %10 to i8*
%12 = load i32*, i32** %9
store i32 0, i32* %12
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 1
br i1 %14, label %18, label %15
15: ; preds = %4
%16 = load i32, i32* %6
%17 = icmp sgt i32 %16, 31
br i1 %17, label %18, label %19
18: ; preds = %15, %4
store i32 -1, i32* %5
br label %84
19: ; preds = %15
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 1
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = load i32, i32* %7
%24 = icmp sgt i32 %23, 12
br i1 %24, label %25, label %26
25: ; preds = %22, %19
store i32 -1, i32* %5
br label %84
26: ; preds = %22
%27 = load i32, i32* %8
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %51
29: ; preds = %26
%30 = load i32, i32* %8
%31 = icmp slt i32 %30, 100
br i1 %31, label %32, label %51
32: ; preds = %29
%33 = load i32, i32* %8
%34 = icmp slt i32 %33, 10
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 0
%37 = load i32, i32* %8
%38 = call i32 @sprintf(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %37)
br label %43
39: ; preds = %32
%40 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 0
%41 = load i32, i32* %8
%42 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %39, %35
%44 = load i32, i32* @stderr
%45 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 0
%46 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i8* %45)
%47 = load i32, i32* @stderr
%48 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 0
%49 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 0
%50 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %48, i8* %49)
br label %51
51: ; preds = %43, %29, %26
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 4800
%54 = load i32, i32* %7
%55 = sub nsw i32 %54, 14
%56 = sdiv i32 %55, 12
%57 = add nsw i32 %53, %56
%58 = mul nsw i32 1461, %57
%59 = sdiv i32 %58, 4
%60 = load i32, i32* %7
%61 = sub nsw i32 %60, 2
%62 = load i32, i32* %7
%63 = sub nsw i32 %62, 14
%64 = sdiv i32 %63, 12
%65 = mul nsw i32 12, %64
%66 = sub nsw i32 %61, %65
%67 = mul nsw i32 367, %66
%68 = sdiv i32 %67, 12
%69 = add nsw i32 %59, %68
%70 = load i32, i32* %8
%71 = add nsw i32 %70, 4900
%72 = load i32, i32* %7
%73 = sub nsw i32 %72, 14
%74 = sdiv i32 %73, 12
%75 = add nsw i32 %71, %74
%76 = sdiv i32 %75, 100
%77 = mul nsw i32 3, %76
%78 = sdiv i32 %77, 4
%79 = sub nsw i32 %69, %78
%80 = load i32, i32* %6
%81 = add nsw i32 %79, %80
%82 = sub nsw i32 %81, 32075
%83 = load i32*, i32** %9
store i32 %82, i32* %83
store i32 0, i32* %5
br label %84
84: ; preds = %51, %25, %18
%85 = load i32, i32* %5
ret i32 %85
}

LLVM IR (-O2):
@.str = [4 x i8] c"0%d\00"
@.str.1 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.2 = [57 x i8] c"Warning: Gregorian2Julian() has been called for year %s\0A\00"
@.str.3 = [31 x i8] c"Maybe you meant 19%s or 20%s?\0A\00"
define i32 @Gregorian2Julian(i32 %0, i32 %1, i32 %2, i32* nocapture writeonly %3) {
%5 = alloca [3 x i8]
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
store i32 0, i32* %3
%7 = add i32 %0, -32
%8 = icmp ult i32 %7, -31
%9 = add i32 %1, -13
%10 = icmp ult i32 %9, -12
%11 = or i1 %8, %10
br i1 %11, label %48, label %12
12: ; preds = %4
%13 = add i32 %2, -1
%14 = icmp ult i32 %13, 99
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = icmp ult i32 %2, 10
%17 = select i1 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%18 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) %17, i32 %2)
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %6, i8* %6)
br label %23
23: ; preds = %15, %12
%24 = add nsw i32 %2, 4800
%25 = trunc i32 %1 to i8
%26 = sub nuw nsw i8 14, %25
%27 = udiv i8 %26, 12
%28 = zext i8 %27 to i32
%29 = sub nsw i32 %24, %28
%30 = mul nsw i32 %29, 1461
%31 = sdiv i32 %30, 4
%32 = add nuw nsw i32 %1, 65534
%33 = mul nuw nsw i32 %28, 12
%34 = add nuw nsw i32 %32, %33
%35 = trunc i32 %34 to i16
%36 = mul nsw i16 %35, 367
%37 = sdiv i16 %36, 12
%38 = sext i16 %37 to i32
%39 = add nsw i32 %2, 4900
%40 = sub nsw i32 %39, %28
%41 = sdiv i32 %40, 100
%42 = mul nsw i32 %41, 3
%43 = sdiv i32 %42, -4
%44 = add nuw nsw i32 %0, -32075
%45 = add nsw i32 %44, %31
%46 = add nsw i32 %45, %43
%47 = add nsw i32 %46, %38
store i32 %47, i32* %3
br label %48
48: ; preds = %4, %23
%49 = phi i32 [ 0, %23 ], [ -1, %4 ]
ret i32 %49
}