#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 strlen(char const *);
int main() {
  const char *text = "abcd";
  int shift = 24;
  int answ = 0;
  for (int i = 0; i < strlen(text); i++) {
    answ |= text[i] << shift;
    shift -= 8;
  }
  printf("answ=%i\n", answ);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x18,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    1199 <main+0x79>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x14(%rbp),%ecx
shl    %cl,%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114f <main+0x2f>
mov    -0x18(%rbp),%esi
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1175 <main+0x55>
mov    $0x18,%ebx
xor    %ebp,%ebp
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl 0x0(%rbp,%r14,1),%eax
mov    %ebx,%ecx
shl    %cl,%eax
or     %eax,%r15d
add    $0xfffffff8,%ebx
add    $0x1,%rbp
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1150 <main+0x30>
jmp    1178 <main+0x58>
xor    %r15d,%r15d
lea    0xe86(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"abcd\00"
@.str.1 = [9 x i8] c"answ=%i\0A\00"
define i32 @main() {
%1 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = icmp sgt i32 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %6, %0
%4 = phi i32 [ 0, %0 ], [ %14, %6 ]
%5 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %4)
ret i32 0
6: ; preds = %0, %6
%7 = phi i64 [ %16, %6 ], [ 0, %0 ]
%8 = phi i32 [ %14, %6 ], [ 0, %0 ]
%9 = phi i32 [ %15, %6 ], [ 24, %0 ]
%10 = getelementptr inbounds [5 x i8], [5 x i8]* @.str, i64 0, i64 %7
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = shl i32 %12, %9
%14 = or i32 %13, %8
%15 = add nsw i32 %9, -8
%16 = add nuw nsw i64 %7, 1
%17 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %6, label %3
}