#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 */
typedef int uint64_t;

/* Variables and functions */
int gx_fromhex(char);
void gx_decode_zZ_packet(char *from, uint64_t *mem_addr_ptr) {
  int i = 0;
  char ch;
  *mem_addr_ptr = 0;
  while ((ch = from[i++]) != ',') {
    *mem_addr_ptr = *mem_addr_ptr << 4;
    *mem_addr_ptr |= gx_fromhex(ch) & 0x0f;
  }
}


x86 assembly (clang, -O0):
<gx_decode_zZ_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
movsbl %al,%eax
cmp    $0x2c,%eax
je     117f <gx_decode_zZ_packet+0x6f>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
shl    $0x4,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movsbl -0x15(%rbp),%edi
call   1030 <gx_fromhex@plt>
mov    %eax,%ecx
and    $0xf,%ecx
mov    -0x10(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
jmp    1131 <gx_decode_zZ_packet+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gx_decode_zZ_packet>:
push   %r14
push   %rbx
push   %rax
movl   $0x0,(%rsi)
mov    (%rdi),%cl
cmp    $0x2c,%cl
je     1153 <gx_decode_zZ_packet+0x43>
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0x1,%rbx
xor    %eax,%eax
nopl   (%rax)
shl    $0x4,%eax
mov    %eax,(%r14)
movsbl %cl,%edi
call   1030 <gx_fromhex@plt>
and    $0xf,%eax
or     (%r14),%eax
mov    %eax,(%r14)
movzbl (%rbx),%ecx
add    $0x1,%rbx
cmp    $0x2c,%cl
jne    1130 <gx_decode_zZ_packet+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @gx_decode_zZ_packet(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 0, i32* %5
%7 = load i32*, i32** %4
store i32 0, i32* %7
br label %8
8: ; preds = %17, %2
%9 = load i8*, i8** %3
%10 = load i32, i32* %5
%11 = add nsw i32 %10, 1
store i32 %11, i32* %5
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds i8, i8* %9, i64 %12
%14 = load i8, i8* %13
store i8 %14, i8* %6
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 44
br i1 %16, label %17, label %28
17: ; preds = %8
%18 = load i32*, i32** %4
%19 = load i32, i32* %18
%20 = shl i32 %19, 4
%21 = load i32*, i32** %4
store i32 %20, i32* %21
%22 = load i8, i8* %6
%23 = call i32 @gx_fromhex(i8 signext %22)
%24 = and i32 %23, 15
%25 = load i32*, i32** %4
%26 = load i32, i32* %25
%27 = or i32 %26, %24
store i32 %27, i32* %25
br label %8
28: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @gx_decode_zZ_packet(i8* nocapture %0, i32* nocapture %1) {
store i32 0, i32* %1
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 44
br i1 %4, label %18, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %9, %5 ], [ 0, %2 ]
%7 = phi i8 [ %16, %5 ], [ %3, %2 ]
%8 = phi i32 [ %14, %5 ], [ 0, %2 ]
%9 = add nuw i64 %6, 1
%10 = shl i32 %8, 4
store i32 %10, i32* %1
%11 = tail call i32 @gx_fromhex(i8 signext %7)
%12 = and i32 %11, 15
%13 = load i32, i32* %1
%14 = or i32 %13, %12
store i32 %14, i32* %1
%15 = getelementptr inbounds i8, i8* %0, i64 %9
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 44
br i1 %17, label %18, label %5
18: ; preds = %5, %2
ret void
}