#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 atoi(char *);
int /*<<< orphan*/ printf(char *, int);
main(int argc, char **argv) {
  int prod1 = 1;
  int prod2 = 1;
  int modulo = atoi(argv[1]);
  for (int arg = 2; arg < argc; arg++) {
    prod1 *= atoi(argv[arg]) % modulo;
    prod2 *= atoi(argv[arg]);
    printf("1: prod1 = %d\n", prod1);
    printf("1: prod2 = %d\n", prod2);
  }
  prod1 %= modulo;
  prod2 %= modulo;
  printf("2: prod1 = %d\n", prod1);
  printf("2: prod2 = %d\n", prod2);
  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)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c7 <main+0xa7>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <atoi@plt>
cltd
idivl  -0x1c(%rbp)
imul   -0x14(%rbp),%edx
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <atoi@plt>
imul   -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115b <main+0x3b>
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r12d
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %eax,%r15d
mov    $0x1,%ebp
mov    $0x1,%ebx
cmp    $0x3,%r12d
jl     119a <main+0x7a>
mov    %r12d,%r12d
mov    $0x1,%ebx
mov    $0x2,%r13d
mov    $0x1,%ebp
mov    (%r14,%r13,8),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
cltd
idiv   %r15d
imul   %edx,%ebx
imul   %ecx,%ebp
lea    0xe84(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xe85(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%r13
cmp    %r13,%r12
jne    1160 <main+0x40>
mov    %ebx,%eax
cltd
idiv   %r15d
mov    %edx,%esi
mov    %ebp,%eax
cltd
idiv   %r15d
mov    %edx,%ebx
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe70(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"1: prod1 = %d\0A\00"
@.str.1 = [15 x i8] c"1: prod2 = %d\0A\00"
@.str.2 = [15 x i8] c"2: prod1 = %d\0A\00"
@.str.3 = [15 x i8] c"2: prod2 = %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
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 1, i32* %7
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %8
store i32 2, i32* %9
br label %14
14: ; preds = %41, %2
%15 = load i32, i32* %9
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %44
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
%25 = load i32, i32* %8
%26 = srem i32 %24, %25
%27 = load i32, i32* %6
%28 = mul nsw i32 %27, %26
store i32 %28, i32* %6
%29 = load i8**, i8*** %5
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
%35 = load i32, i32* %7
%36 = mul nsw i32 %35, %34
store i32 %36, i32* %7
%37 = load i32, i32* %6
%38 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %7
%40 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %18
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
store i32 %43, i32* %9
br label %14
44: ; preds = %14
%45 = load i32, i32* %8
%46 = load i32, i32* %6
%47 = srem i32 %46, %45
store i32 %47, i32* %6
%48 = load i32, i32* %8
%49 = load i32, i32* %7
%50 = srem i32 %49, %48
store i32 %50, i32* %7
%51 = load i32, i32* %6
%52 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %7
%54 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %53)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"1: prod1 = %d\0A\00"
@.str.1 = [15 x i8] c"1: prod2 = %d\0A\00"
@.str.2 = [15 x i8] c"2: prod1 = %d\0A\00"
@.str.3 = [15 x i8] c"2: prod2 = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = icmp sgt i32 %0, 2
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = zext i32 %0 to i64
br label %16
9: ; preds = %16, %2
%10 = phi i32 [ 1, %2 ], [ %25, %16 ]
%11 = phi i32 [ 1, %2 ], [ %24, %16 ]
%12 = srem i32 %11, %5
%13 = srem i32 %10, %5
%14 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %13)
ret i32 0
16: ; preds = %7, %16
%17 = phi i64 [ 2, %7 ], [ %28, %16 ]
%18 = phi i32 [ 1, %7 ], [ %24, %16 ]
%19 = phi i32 [ 1, %7 ], [ %25, %16 ]
%20 = getelementptr inbounds i8*, i8** %1, i64 %17
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
%23 = srem i32 %22, %5
%24 = mul nsw i32 %23, %18
%25 = mul nsw i32 %22, %19
%26 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %24)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%28 = add nuw nsw i64 %17, 1
%29 = icmp eq i64 %28, %8
br i1 %29, label %9, label %16
}