void CalculateStemsBranches(int year, int *stems, int *branches) {
  int sc = year - 2000;
  *stems = (7 + sc) % 10;
  *branches = (5 + sc) % 12;
  if (*stems < 0)
    *stems += 10;
  if (*branches < 0)
    *branches += 12;
}


x86 assembly (clang, -O0):
<CalculateStemsBranches>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x7d0,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x7,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
mov    %edx,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x5,%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
mov    %edx,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jge    115a <CalculateStemsBranches+0x5a>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0xa,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jge    1172 <CalculateStemsBranches+0x72>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0xc,%ecx
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalculateStemsBranches>:
lea    -0x7c9(%rdi),%eax
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
neg    %eax
add    %edi,%eax
add    $0xfffff837,%eax
mov    %eax,(%rsi)
mov    %edi,%eax
add    $0xfffff835,%eax
cltq
imul   $0x2aaaaaab,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x21,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,2),%eax
neg    %eax
add    %edi,%eax
add    $0xfffff835,%eax
mov    %eax,(%rdx)
mov    (%rsi),%ecx
test   %ecx,%ecx
js     1165 <CalculateStemsBranches+0x65>
test   %eax,%eax
js     1170 <CalculateStemsBranches+0x70>
ret
add    $0xa,%ecx
mov    %ecx,(%rsi)
mov    (%rdx),%eax
test   %eax,%eax
jns    1164 <CalculateStemsBranches+0x64>
add    $0xc,%eax
mov    %eax,(%rdx)
ret

LLVM IR (-O0):
define void @CalculateStemsBranches(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i32, i32* %4
%9 = sub nsw i32 %8, 2000
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = add nsw i32 7, %10
%12 = srem i32 %11, 10
%13 = load i32*, i32** %5
store i32 %12, i32* %13
%14 = load i32, i32* %7
%15 = add nsw i32 5, %14
%16 = srem i32 %15, 12
%17 = load i32*, i32** %6
store i32 %16, i32* %17
%18 = load i32*, i32** %5
%19 = load i32, i32* %18
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %3
%22 = load i32*, i32** %5
%23 = load i32, i32* %22
%24 = add nsw i32 %23, 10
store i32 %24, i32* %22
br label %25
25: ; preds = %21, %3
%26 = load i32*, i32** %6
%27 = load i32, i32* %26
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i32*, i32** %6
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 12
store i32 %32, i32* %30
br label %33
33: ; preds = %29, %25
ret void
}

LLVM IR (-O2):
define void @CalculateStemsBranches(i32 %0, i32* nocapture %1, i32* nocapture %2) {
%4 = add nsw i32 %0, -1993
%5 = srem i32 %4, 10
store i32 %5, i32* %1
%6 = add nsw i32 %0, -1995
%7 = srem i32 %6, 12
store i32 %7, i32* %2
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = add nsw i32 %8, 10
store i32 %11, i32* %1
%12 = load i32, i32* %2
br label %13
13: ; preds = %10, %3
%14 = phi i32 [ %12, %10 ], [ %7, %3 ]
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = add nsw i32 %14, 12
store i32 %17, i32* %2
br label %18
18: ; preds = %16, %13
ret void
}