#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*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
int main(int argc, char *argv[]) {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  printf("%d\n", (a + b) % c);
  printf("%d\n", (a % c + b % c) % c);
  printf("%d\n", (a * b) % c);
  printf("%d\n", (a % c * b % c) % c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,%esi
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0x20(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    %edx,%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,%esi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,%esi
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,%eax
imul   -0x18(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,%esi
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
add    0xc(%rsp),%eax
cltd
idivl  0x4(%rsp)
lea    0xeb5(%rip),%rbx
mov    %rbx,%rdi
mov    %edx,%esi
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
mov    0x4(%rsp),%esi
cltd
idiv   %esi
mov    %edx,%ecx
mov    0x8(%rsp),%eax
cltd
idiv   %esi
add    %edx,%ecx
mov    %ecx,%eax
cltd
idiv   %esi
mov    %rbx,%rdi
mov    %edx,%esi
call   1030 <printf@plt>
mov    0x8(%rsp),%eax
imul   0xc(%rsp),%eax
cltd
idivl  0x4(%rsp)
mov    %rbx,%rdi
mov    %edx,%esi
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
mov    0x4(%rsp),%ecx
cltd
idiv   %ecx
mov    %edx,%eax
imul   0x8(%rsp),%eax
cltd
idiv   %ecx
mov    %rbx,%rdi
mov    %edx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %6, i32* %7, i32* %8)
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = add nsw i32 %10, %11
%13 = load i32, i32* %8
%14 = srem i32 %12, %13
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %6
%17 = load i32, i32* %8
%18 = srem i32 %16, %17
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = srem i32 %19, %20
%22 = add nsw i32 %18, %21
%23 = load i32, i32* %8
%24 = srem i32 %22, %23
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = mul nsw i32 %26, %27
%29 = load i32, i32* %8
%30 = srem i32 %28, %29
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %6
%33 = load i32, i32* %8
%34 = srem i32 %32, %33
%35 = load i32, i32* %7
%36 = mul nsw i32 %34, %35
%37 = load i32, i32* %8
%38 = srem i32 %36, %37
%39 = load i32, i32* %8
%40 = srem i32 %38, %39
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = add nsw i32 %11, %10
%13 = load i32, i32* %5
%14 = srem i32 %12, %13
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = load i32, i32* %5
%18 = srem i32 %16, %17
%19 = load i32, i32* %4
%20 = srem i32 %19, %17
%21 = add nsw i32 %20, %18
%22 = srem i32 %21, %17
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = mul nsw i32 %25, %24
%27 = load i32, i32* %5
%28 = srem i32 %26, %27
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %3
%31 = load i32, i32* %5
%32 = srem i32 %30, %31
%33 = load i32, i32* %4
%34 = mul nsw i32 %33, %32
%35 = srem i32 %34, %31
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
ret i32 0
}