#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 EXIT_SUCCESS;
int /*<<< orphan*/ bitprint(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
unsigned int rotate_left(unsigned int, int);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int left_count;
  unsigned num;
  unsigned shifted_num;
  printf("\nMarc Woodyard.  Lab 8.\n");
  do {
    printf("\nEnter an unsigned integer value (0 to stop):  ");
    scanf("%u", &num);
    if (num != 0) {
      printf("\nEnter an integer value for the left shift:  ");
      scanf("%d", &left_count);
      printf("\nOriginal is %u \n", num);
      bitprint(num);
      shifted_num = rotate_left(num, left_count);
      bitprint(shifted_num);
      printf("Shifted it is %u \n", shifted_num);
    }
  } while (num != 0);
  printf("\n\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
je     11e7 <main+0xa7>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xc(%rbp),%esi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
call   1030 <bitprint@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <rotate_left@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <bitprint@plt>
mov    -0x10(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ec <main+0xac>
cmpl   $0x0,-0xc(%rbp)
jne    115d <main+0x1d>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf27(%rip),%rdi
call   1030 <puts@plt>
lea    0xec2(%rip),%r15
mov    %rsp,%rbx
lea    0x4(%rsp),%rbp
lea    0xee7(%rip),%r14
lea    0xef2(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,(%rsp)
je     120e <main+0xbe>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9b(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    (%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%edi
call   1040 <bitprint@plt>
mov    (%rsp),%edi
mov    0x4(%rsp),%esi
call   1070 <rotate_left@plt>
mov    %eax,%r13d
mov    %eax,%edi
call   1040 <bitprint@plt>
mov    %r12,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,(%rsp)
jne    1190 <main+0x40>
lea    0xe5f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\0AMarc Woodyard. Lab 8.\0A\00"
@.str.1 = [48 x i8] c"\0AEnter an unsigned integer value (0 to stop): \00"
@.str.2 = [3 x i8] c"%u\00"
@.str.3 = [46 x i8] c"\0AEnter an integer value for the left shift: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [18 x i8] c"\0AOriginal is %u \0A\00"
@.str.6 = [19 x i8] c"Shifted it is %u \0A\00"
@.str.7 = [3 x i8] c"\0A\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %26, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %25
11: ; preds = %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = call i32 @bitprint(i32 %16)
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = call i32 @rotate_left(i32 %18, i32 %19)
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = call i32 @bitprint(i32 %21)
%23 = load i32, i32* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %11, %6
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
%28 = icmp ne i32 %27, 0
br i1 %28, label %6, label %29
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%31 = load i32, i32* @EXIT_SUCCESS
ret i32 %31
}

LLVM IR (-O2):
@.str.1 = [48 x i8] c"\0AEnter an unsigned integer value (0 to stop): \00"
@.str.2 = [3 x i8] c"%u\00"
@.str.3 = [46 x i8] c"\0AEnter an integer value for the left shift: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [18 x i8] c"\0AOriginal is %u \0A\00"
@.str.6 = [19 x i8] c"Shifted it is %u \0A\00"
@EXIT_SUCCESS = global i32 0
@str = [24 x i8] c"\0AMarc Woodyard. Lab 8.\00"
@str.8 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %6
6: ; preds = %11, %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %25, label %11
11: ; preds = %6
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %2
%17 = call i32 @bitprint(i32 %16)
%18 = load i32, i32* %2
%19 = load i32, i32* %1
%20 = call i32 @rotate_left(i32 %18, i32 %19)
%21 = call i32 @bitprint(i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %20)
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %6
25: ; preds = %6, %11
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.8, i64 0, i64 0))
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}