#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*/ snprintf(char *, int, char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
char *strstr(char *, char *);
unsigned int readBits(char *cmdResult) {
  int a, b, c, d;
  char *jj;
  char ss[140];
  unsigned int ff;
  char sa[2] = "\0", sb[2] = "\0", sc[2] = "\0", sd[2] = "\0";
  jj = strstr(cmdResult, "BITS:");
  strcpy(ss, (jj + 6));
  snprintf(sa, 1, "%c", ss[0]);
  snprintf(sb, 1, "%c", ss[1]);
  snprintf(sc, 1, "%c", ss[3]);
  snprintf(sd, 1, "%c", ss[4]);
  a = atoi(sa);
  b = atoi(sb);
  c = atoi(sc);
  d = atoi(sd);
  ff = a * 4096 + b * 256 + c * 16 + d;
  return (ff);
}


x86 assembly (clang, -O0):
<readBits>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xb6(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <memset@plt>
lea    -0xb8(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <memset@plt>
lea    -0xba(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <memset@plt>
lea    -0xbc(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x20(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x6,%rsi
call   1030 <strcpy@plt>
lea    -0xb6(%rbp),%rdi
mov    $0x1,%esi
lea    0xe20(%rip),%rdx
movsbl -0xb0(%rbp),%ecx
call   1040 <snprintf@plt>
lea    -0xb8(%rbp),%rdi
mov    $0x1,%esi
lea    0xe01(%rip),%rdx
movsbl -0xaf(%rbp),%ecx
call   1040 <snprintf@plt>
lea    -0xba(%rbp),%rdi
mov    $0x1,%esi
lea    0xde2(%rip),%rdx
movsbl -0xad(%rbp),%ecx
call   1040 <snprintf@plt>
lea    -0xbc(%rbp),%rdi
mov    $0x1,%esi
lea    0xdc3(%rip),%rdx
movsbl -0xac(%rbp),%ecx
call   1040 <snprintf@plt>
lea    -0xb6(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0xc(%rbp)
lea    -0xb8(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x10(%rbp)
lea    -0xba(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    -0xbc(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
shl    $0xc,%eax
mov    -0x10(%rbp),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    %ecx,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readBits>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
movw   $0x0,0xe(%rsp)
movw   $0x0,0xc(%rsp)
movw   $0x0,0xa(%rsp)
movw   $0x0,0x8(%rsp)
lea    0xe8c(%rip),%rsi
call   1060 <strstr@plt>
lea    0x6(%rax),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
movsbl 0x10(%rsp),%ecx
lea    0xe73(%rip),%rbx
lea    0xe(%rsp),%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1040 <snprintf@plt>
movsbl 0x11(%rsp),%ecx
lea    0xc(%rsp),%r15
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1040 <snprintf@plt>
movsbl 0x13(%rsp),%ecx
lea    0xa(%rsp),%r12
mov    %r12,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1040 <snprintf@plt>
movsbl 0x14(%rsp),%ecx
lea    0x8(%rsp),%r13
mov    %r13,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1040 <snprintf@plt>
mov    %r14,%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1050 <atoi@plt>
shl    $0xc,%r14d
shl    $0x8,%ebp
add    %r14d,%ebp
shl    $0x4,%ebx
add    %ebp,%ebx
add    %ebx,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"BITS:\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @readBits(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [140 x i8]
%9 = alloca i32
%10 = alloca [2 x i8]
%11 = alloca [2 x i8]
%12 = alloca [2 x i8]
%13 = alloca [2 x i8]
store i8* %0, i8** %2
%14 = bitcast [2 x i8]* %10 to i8*
%15 = bitcast [2 x i8]* %11 to i8*
%16 = bitcast [2 x i8]* %12 to i8*
%17 = bitcast [2 x i8]* %13 to i8*
%18 = load i8*, i8** %2
%19 = call i8* @strstr(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %7
%20 = getelementptr inbounds [140 x i8], [140 x i8]* %8, i64 0, i64 0
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i64 6
%23 = call i32 @strcpy(i8* %20, i8* %22)
%24 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%25 = getelementptr inbounds [140 x i8], [140 x i8]* %8, i64 0, i64 0
%26 = load i8, i8* %25
%27 = call i32 @snprintf(i8* %24, i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %26)
%28 = getelementptr inbounds [2 x i8], [2 x i8]* %11, i64 0, i64 0
%29 = getelementptr inbounds [140 x i8], [140 x i8]* %8, i64 0, i64 1
%30 = load i8, i8* %29
%31 = call i32 @snprintf(i8* %28, i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %30)
%32 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%33 = getelementptr inbounds [140 x i8], [140 x i8]* %8, i64 0, i64 3
%34 = load i8, i8* %33
%35 = call i32 @snprintf(i8* %32, i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %34)
%36 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%37 = getelementptr inbounds [140 x i8], [140 x i8]* %8, i64 0, i64 4
%38 = load i8, i8* %37
%39 = call i32 @snprintf(i8* %36, i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %38)
%40 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%41 = call i32 @atoi(i8* %40)
store i32 %41, i32* %3
%42 = getelementptr inbounds [2 x i8], [2 x i8]* %11, i64 0, i64 0
%43 = call i32 @atoi(i8* %42)
store i32 %43, i32* %4
%44 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%45 = call i32 @atoi(i8* %44)
store i32 %45, i32* %5
%46 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%47 = call i32 @atoi(i8* %46)
store i32 %47, i32* %6
%48 = load i32, i32* %3
%49 = mul nsw i32 %48, 4096
%50 = load i32, i32* %4
%51 = mul nsw i32 %50, 256
%52 = add nsw i32 %49, %51
%53 = load i32, i32* %5
%54 = mul nsw i32 %53, 16
%55 = add nsw i32 %52, %54
%56 = load i32, i32* %6
%57 = add nsw i32 %55, %56
store i32 %57, i32* %9
%58 = load i32, i32* %9
ret i32 %58
}

LLVM IR (-O2):
@.str = [6 x i8] c"BITS:\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @readBits(i8* %0) {
%2 = alloca [140 x i8]
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = getelementptr inbounds [140 x i8], [140 x i8]* %2, i64 0, i64 0
%8 = bitcast i16* %3 to i8*
store i16 0, i16* %3
%9 = bitcast i16* %4 to i8*
store i16 0, i16* %4
%10 = bitcast i16* %5 to i8*
store i16 0, i16* %5
%11 = bitcast i16* %6 to i8*
store i16 0, i16* %6
%12 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds i8, i8* %12, i64 6
%14 = call i32 @strcpy(i8* %7, i8* %13)
%15 = load i8, i8* %7
%16 = call i32 @snprintf(i8* %8, i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %15)
%17 = getelementptr inbounds [140 x i8], [140 x i8]* %2, i64 0, i64 1
%18 = load i8, i8* %17
%19 = call i32 @snprintf(i8* %9, i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %18)
%20 = getelementptr inbounds [140 x i8], [140 x i8]* %2, i64 0, i64 3
%21 = load i8, i8* %20
%22 = call i32 @snprintf(i8* %10, i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %21)
%23 = getelementptr inbounds [140 x i8], [140 x i8]* %2, i64 0, i64 4
%24 = load i8, i8* %23
%25 = call i32 @snprintf(i8* %11, i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %24)
%26 = call i32 @atoi(i8* %8)
%27 = call i32 @atoi(i8* %9)
%28 = call i32 @atoi(i8* %10)
%29 = call i32 @atoi(i8* %11)
%30 = shl nsw i32 %26, 12
%31 = shl nsw i32 %27, 8
%32 = add nsw i32 %31, %30
%33 = shl nsw i32 %28, 4
%34 = add nsw i32 %32, %33
%35 = add nsw i32 %34, %29
ret i32 %35
}