#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 *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
unsigned int subChangeQWORD(char *);
int main(void) {
  unsigned int szSerialNum_alt1;
  unsigned int szSerialNum_alt2;
  unsigned int szSerialNum_alt3;
  unsigned int szSerialNum_alt4;
  const int iterations = 4;
  char serial[35] = "serialnumbergoesherenowandstuffyay!";
  char substring[9];
  int offset = 0;
  int i;
  for (i = 0; i < iterations; i++) {
    strncpy(substring, serial + offset, 8);
    substring[8] = '\0';
    printf("%s:\n", substring);
    offset += 9;
    switch (iterations) {
    case 1:
      szSerialNum_alt1 = subChangeQWORD((char *)substring);
      break;
    case 2:
      szSerialNum_alt2 = subChangeQWORD((char *)substring);
      break;
    case 3:
      szSerialNum_alt3 = subChangeQWORD((char *)substring);
      break;
    case 4:
      szSerialNum_alt4 = subChangeQWORD((char *)substring);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x23,%edx
call   1060 <memcpy@plt>
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x4,-0x54(%rbp)
jge    11d3 <main+0x93>
lea    -0x49(%rbp),%rdi
lea    -0x40(%rbp),%rsi
movslq -0x50(%rbp),%rax
add    %rax,%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x41(%rbp)
lea    -0x49(%rbp),%rsi
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
mov    -0x50(%rbp),%eax
add    $0x9,%eax
mov    %eax,-0x50(%rbp)
lea    -0x49(%rbp),%rdi
call   1050 <subChangeQWORD@plt>
mov    %eax,-0x14(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1179 <main+0x39>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movaps 0xed2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x21796179,0x2f(%rsp)
21
lea    0x7(%rsp),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
lea    0xea9(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <subChangeQWORD@plt>
lea    0x19(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <subChangeQWORD@plt>
lea    0x22(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <subChangeQWORD@plt>
lea    0x2b(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <subChangeQWORD@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.serial = [35 x i8] c"serialnumbergoesherenowandstuffyay!"
@.str = [5 x i8] c"%s:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [35 x i8]
%8 = alloca [9 x i8]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store i32 4, i32* %6
%11 = bitcast [35 x i8]* %7 to i8*
store i32 0, i32* %9
store i32 0, i32* %10
br label %12
12: ; preds = %29, %0
%13 = load i32, i32* %10
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %32
15: ; preds = %12
%16 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 0
%17 = getelementptr inbounds [35 x i8], [35 x i8]* %7, i64 0, i64 0
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = call i32 @strncpy(i8* %16, i8* %20, i32 8)
%22 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 8
store i8 0, i8* %22
%23 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 9
store i32 %26, i32* %9
%27 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 0
%28 = call i32 @subChangeQWORD(i8* %27)
store i32 %28, i32* %5
br label %29
29: ; preds = %15
%30 = load i32, i32* %10
%31 = add nsw i32 %30, 1
store i32 %31, i32* %10
br label %12
32: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@__const.main.serial = [35 x i8] c"serialnumbergoesherenowandstuffyay!"
@.str = [5 x i8] c"%s:\0A\00"
define i32 @main() {
%1 = alloca [35 x i8]
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [35 x i8], [35 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 8
%6 = call i32 @strncpy(i8* %4, i8* %3, i32 8)
store i8 0, i8* %5
%7 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = call i32 @subChangeQWORD(i8* %4)
%9 = getelementptr inbounds [35 x i8], [35 x i8]* %1, i64 0, i64 9
%10 = call i32 @strncpy(i8* %4, i8* %9, i32 8)
store i8 0, i8* %5
%11 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %4)
%12 = call i32 @subChangeQWORD(i8* %4)
%13 = getelementptr inbounds [35 x i8], [35 x i8]* %1, i64 0, i64 18
%14 = call i32 @strncpy(i8* %4, i8* %13, i32 8)
store i8 0, i8* %5
%15 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %4)
%16 = call i32 @subChangeQWORD(i8* %4)
%17 = getelementptr inbounds [35 x i8], [35 x i8]* %1, i64 0, i64 27
%18 = call i32 @strncpy(i8* %4, i8* %17, i32 8)
store i8 0, i8* %5
%19 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %4)
%20 = call i32 @subChangeQWORD(i8* %4)
ret i32 0
}