#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 */
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ mpz_add_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_mod(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
void g(mpz_t res, mpz_t s, mpz_t y, mpz_t n) {
  mpz_mul(res, y, s);
  mpz_mod(res, res, n);
  mpz_add_ui(res, res, 1);
  mpz_mod(res, res, n);
  mpz_mul_ui(res, res, 2);
  mpz_mod(res, res, n);
}


x86 assembly (clang, -O0):
<g>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1040 <mpz_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <mpz_mod@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
call   1030 <mpz_add_ui@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <mpz_mod@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    $0x2,%edx
call   1060 <mpz_mul_ui@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <mpz_mod@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g>:
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %esi,%eax
mov    %edi,%ebp
mov    %edx,%esi
mov    %eax,%edx
call   1040 <mpz_mul@plt>
mov    %ebp,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1050 <mpz_mod@plt>
mov    %ebp,%edi
mov    %ebp,%esi
mov    $0x1,%edx
call   1030 <mpz_add_ui@plt>
mov    %ebp,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1050 <mpz_mod@plt>
mov    %ebp,%edi
mov    %ebp,%esi
mov    $0x2,%edx
call   1060 <mpz_mul_ui@plt>
mov    %ebp,%edi
mov    %ebp,%esi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <mpz_mod@plt>

LLVM IR (-O0):
define void @g(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = call i32 @mpz_mul(i32 %9, i32 %10, i32 %11)
%13 = load i32, i32* %5
%14 = load i32, i32* %5
%15 = load i32, i32* %8
%16 = call i32 @mpz_mod(i32 %13, i32 %14, i32 %15)
%17 = load i32, i32* %5
%18 = load i32, i32* %5
%19 = call i32 @mpz_add_ui(i32 %17, i32 %18, i32 1)
%20 = load i32, i32* %5
%21 = load i32, i32* %5
%22 = load i32, i32* %8
%23 = call i32 @mpz_mod(i32 %20, i32 %21, i32 %22)
%24 = load i32, i32* %5
%25 = load i32, i32* %5
%26 = call i32 @mpz_mul_ui(i32 %24, i32 %25, i32 2)
%27 = load i32, i32* %5
%28 = load i32, i32* %5
%29 = load i32, i32* %8
%30 = call i32 @mpz_mod(i32 %27, i32 %28, i32 %29)
ret void
}

LLVM IR (-O2):
define void @g(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @mpz_mul(i32 %0, i32 %2, i32 %1)
%6 = tail call i32 @mpz_mod(i32 %0, i32 %0, i32 %3)
%7 = tail call i32 @mpz_add_ui(i32 %0, i32 %0, i32 1)
%8 = tail call i32 @mpz_mod(i32 %0, i32 %0, i32 %3)
%9 = tail call i32 @mpz_mul_ui(i32 %0, i32 %0, i32 2)
%10 = tail call i32 @mpz_mod(i32 %0, i32 %0, i32 %3)
ret void
}